Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrong Error???

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
When my application starts it loads a couple of settings
on the OnFormActivate Event. It also sets the forms style:
either fsStayOnTop or fsNormal. But when this is run on
FormActivate i keep getting the error :
"Cannot change visible in OnShow or OnHide" of the EInvalidOperation type. This only happens when I try to change the form style while the form is being activated.

Can anyone help me with this problem?

Thanx allot,

BobbaFet Everybody has a right to my opinion.
E-mail me at cwcon@programmer.net
 
it might pay to wait until the form has been created be for you start changing it
 
If you look at the help for OnCreate which lists form creation event order you might suppose that your form WILL have been created by the time OnActivate happens, so Safrasers reply probobly leaves you in dark so to speak.

I have apps which run message dialogs on start-up, and still have to find a way to get the main form to either
(a) Stay hidden or
(b) Maximise propery
before the dialog is displayed.

Safraser is correct of course the short answer is don't do anything that changes the visible property of a form in FormActivate, but that dosent solve your problem,
and it's no use sticking in delays.
There must be a correct way to handle this sort of thing
does anyone know?

 
Thanx guys,

The onCreate tip worked, even though I always thought that
the onCreate event came before the onActivate event.

BobbaFet Everybody has a right to my opinion.
E-mail me at cwcon@programmer.net
 
If it's the first (and maybe the only form), Edit the .dpr file. (Project1.dpr in my case)

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);

// Do your stuff here

Application.Run;
end.

Of course all Events such as Create, Activate will be executed before you stuff...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top