Solved

MainForm.FormShow being called before Application.Run

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Image capture and Deploy method is consist on two phases. In our first phase we capture the image of windows from the PC in which Windows and others softwares are already installed. In second phase we deploy the created image on new PC in which we…
Hi Friends, These registry tweaks will help you optimizing your Windows 7 system for any VDI. This will improve the machine performanance and can be used on normal systems also. These are few registry tweaks which will add value by enhancing the …
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

747 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

14 Experts available now in Live!

Get 1:1 Help Now