Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Stefan Wuebbe
 To: Paul Mannes
  Where is Paul Mannes?
 Virginia - United States
 Paul Mannes
Subject: RE: Form Object functions App vs Exe
Thread ID: 395732 Message ID: 395747 # Views: 45 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Projects and Design
Date: Saturday, January 18, 2014 10:00:37 AM         

> I have a form that I saved as an Object for use as a Security Login
> I have a main.prg which has a public variable declaration of this form object ofrmSecurityControl
> I have a main form that is called from the main.prg followed by a Read Events
> ***************************
> ex:
> public ofrmSecurityControl
> .... && parms for object parameters set..
> ofrmSecurityControl = createobject("SecurityControl",parms....)
> do form frmMain name ofrmMain
> read events
> ***************************
> Here is the issue:
> In the frmMain.Init the ofrmSecurityControl.Show() is called.
> When I run this as an App for testing, it stops at the .Show() and allows entry on the ofrmSecurityControl form
> When I run this as an Exe in the same environment, it blows right by the .Show() and creates a problem....
> The main form is Modeless and frmSecurityControl is Modal
> The main form is ShowWindow - 2-As Top-Level Form and the frmSecurityControl is ShowWindow - 1-In Top-Level Form..
> Thoughts...Please..
> Paul Mannes

frmMain.Init() is too early because the as-top-level Form (or _screen) that an in-top-level Form needs when it wants to Show() must be fully instantiated and visible.
So that you could put the ofrmSecurityControl.Show() into one of the sub-sequent mainForm events, i.e. Activate() or GotFocus().
I would prefer to put it after the "Do Form .." line into the main.PRG myself though.
(Because Activate() and GotFocus() may run repeatedly, requiring additional "first-time only" code, and since IMO it would not be the job of mainForm to care for the other form in this case, in a "single responsibility" pattern sense.)

Or you could use a mainForm.Timer object or make the ofrmSecurityControl as-top-level too so that you could Show() it in main.prg before frmMain runs if you want and add an additional, second (or first) Read Events right afterwards (because ofrmSecurityControl as an as-top-level Form could not be modal anymore).



Form Object functions App vs Exe Posted by Paul Mannes @ 1/17/2014 7:26:41 PM
RE: Form Object functions App vs Exe Posted by Stefan Wuebbe @ 1/18/2014 10:00:37 AM