Solved

MainForm.FormShow being called before Application.Run

Posted on 2011-03-07
3
669 Views
Last Modified: 2012-05-11
I have a Delphi project comprising several forms
The forms are created automatically at start up

My main form has a FormCreate and FormShow routine

For the past 6 weeks of development the Mainform.FormShow routine has not been triggered until all the other forms have been successfully created.

Something has changed (I am not sure what) in the last 2 hours, and now the MainForm.FormShow routine is being called immediately after the MainForm.FormCreate.

This causes me problems as the FormShow routine makes use of the other auto created forms.

The MainForm.FormShow call is being triggered by the TCustomForm.CMShowingChanged method (defined in unit Forms) which is triggered by message CM_SHOWINGCHANGED

What could be causing this to be triggered?  

This is really causing me to pull my hair out - any thoughts appreciated.

Jon
0
Comment
Question by:jon_rs
3 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 35058790

Open your project file (.dpr) file
Move the MainForm down the list

However you should not AutoCreate forms unless its a global DataModule, its not good practice.

Forms should be cerated when needed, in this case they should be created in your mainform.formcreate, used and then freed as needed
0
 
LVL 19

Expert Comment

by:Thommy
ID: 35059223
ewangoya is right, DO NOT auto-create forms other than your main form!!!

If you create your forms in mainform.formcreate, you can be sure, that mainform.Formshow triggers after the creation of your forms...
0
 

Author Comment

by:jon_rs
ID: 35059329
Thanks ewangoya

Have moved my form creation to MainForm.FormCreate and everything works again.

Slight frustration that Delphi creates this problem in the first place by defaulting to auto creation of forms ... but problem solved

Jon
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
windows explorer default details view 10 82
Error when logging into pinterest- Java- cookies- browser 1 24
Can't install Windows 7 on Intel NUC 9 50
Upgrading Windows 7 2 23
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question