Solved

MainForm.FormShow being called before Application.Run

Posted on 2011-03-07
3
671 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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

First some basics on Windows 7 Backup.  It has 2 components one is a file based backup which is stored in .zip files each zip is split at around 200 Megabytes and there is the Image Backup which is as the name implies a total image of the partition …
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.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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