?
Solved

MainForm.FormShow being called before Application.Run

Posted on 2011-03-07
3
Medium Priority
?
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

765 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