Solved

MainForm.FormShow being called before Application.Run

Posted on 2011-03-07
3
667 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi and Access based Enumeration 9 44
Reinstall Putty Windows 7 5 44
pass a variable from a list to a batch file using psexec 11 46
HP Pavilion will not boot 15 76
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now