Board index » cppbuilder » When a form appears for the first time
Danny
CBuilder Developer |
Danny
CBuilder Developer |
When a form appears for the first time2007-11-03 05:56:51 PM cppbuilder71 Hi all, I've created several forms (no mainform) very heavy (with many components), in run-time, when a form appears the first time, the process for show it is slow, I think because the components are built; Do exists a procedure for to do this operation when the construction of the form is called? The startup will be more slow, but the effect will be always the same. Thanks in advance. Bye |
Clayton Arends
CBuilder Developer |
2007-11-03 11:12:11 PM
Re:When a form appears for the first time
Form streaming is already performed at construction.
Please post the CPP/H/DFM for one of the forms to "borland.public.attachments" and I'll take a look at it. Preferably send a form that has only standard VCL components on it. Clayton |
Danny
CBuilder Developer |
2007-11-04 01:49:01 AM
Re:When a form appears for the first time
Hi Clayton,
I have found the cause, but not the solution: when a form is showed (Visible=true), is executed the OnResize event (but only the first time), and this rebuild all the components. I would want to force the resize procedure at startup, but I don't know to do. I tried with "Resize()" in AfterConstruction area: the event OnSize is executed, but when I show my form, the OnResize event is executed again. Thank you {smallsort} |
JD
CBuilder Developer |
2007-11-04 09:13:35 AM
Re:When a form appears for the first time
"Danny" < XXXX@XXXXX.COM >wrote:
Quote
had to say. QuoteI have found the cause, but not the solution: when a form is example: Width = Width - 1; or Width = Width + 1; or Height = Height + 1; or Height = Height - 1; I used a variance in the above because it's logical. In most setter methods, if the new width is the same as the old width, no action is taken. Thus the variance of one ... forcing the event. Quote[...] but when I show my form, the OnResize event is too often. Please clerify. ~ JD |
Danny
CBuilder Developer |
2007-11-04 05:23:42 PM
Re:When a form appears for the first time
Hi JD,
I have a form (no mainform) with many graphic components (derived form TGraphicControl), and when there is the OnResize event, the application freezes for a few seconds; I have set "MyForm->BorderStyle=bsSingle" for to avoid that user tries to resize, but I know that is however necessary a first resize for initialize the form. I've noticed that the first OnResize event is generated when the form coming to visible; and so, I looked a way for to anticipate this event (for example in construction zone). I have tried with Width=Width+1 in AterConstruction procedure, and yes, I have the OnResize event, but this has not been enough for avoid that when switch in "MyForm->Visible=true" the event is generated however. This because, in costruction zone the sizes of components arent't set, while when the form coming to visible, the sizes are set. If I succeed, to execute the same steps before displaying the form, I could to simulate an initialization. I know that this is a marginal problem, but it is just a fineness. I'm sorry for my English, I hope to have exposed well the problem. Thank you |
=?utf-8?Q?Asger_J=C3=B8rgensen?=
CBuilder Developer |
2007-11-04 06:59:39 PM
Re:When a form appears for the first time
Hi Danny
If You put a bool Initialized int the H file set it to false in the constructor and then in the OnResize You do like this: if(Initialized)return; Initialized = true; the rest of You code. I don't understand why You use the OnResize event at all when the is bsSingle. If it is to initialize dynamic created component You could use the Form OnShow event in stead it is only called once, just before the form is shown. I am sory if I have have misunderstood You, if so maybe You could upload the form.h and .cpp file to borland.public.attachments Kind regards Asger |
Danny
CBuilder Developer |
2007-11-04 07:46:43 PM
Re:When a form appears for the first time
Hi Asger,
I've solved with a simple way; I've forced the bound rect of the heaviest components in AfterConstruction procedure, so when the OnResize event is called, the component is already initialized. Thank however. Bye |
Mike Ruskai
CBuilder Developer |
2007-11-05 01:20:09 AM
Re:When a form appears for the first time
On or about Sun, 4 Nov 2007 11:59:39 +0100 did Asger Jørgensen
< XXXX@XXXXX.COM >dribble thusly: QuoteI don't understand why You use the OnResize event at of code that need to run once during the lifetime of the form, except for those things I'm sure will run fine in the constructor. |