[DUG] Forms Activate Design decision

John Bird johnkbird at paradise.net.nz
Thu Oct 5 10:01:45 NZDT 2006


It looks to me that if a subsequent modal form FormC is closed then FormB
activate event is NOT fired.   If the subsequent form is non-modal it looks
like the event is fired...this would make some sense if processing for FormB
is suspended while the modal form FormC flies...

I was mainly wondering because of the Rave rvSystem print dialogs...they
seem to be modal as far as I can tell but do fire the activate event on the
form that shows them when they close, particularly the print preview.

John


-----Original Message-----
From: Paul McKenzie [mailto:paul at smss.org.nz] 
Sent: Thursday, 5 October 2006 9:42 a.m.
To: johnkbird at paradise.net.nz; NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Forms Activate Design decision


OnActivate is executed when the Form receives Focus - eg if FormA (A has 
focus) launches FormB (B gets focus) FormB then closes, FormA (A gets 
focus) will execute FormA.OnActivate.

Regards
Paul McKenzie
Wellington
New Zealand



John Bird wrote:

>Those are the reasons I use it as well.
>
>I could separate the loading of the data from form events into a 
>separate
>procedure(s) but I usually put it triggered from the activate event because
>I am often altering the form components, eg making some visible or
invisible
>or enabled/disabled and other visual alterations of the components
according
>to the data being shown and these can only be done once the form is being
>activated.
>
>OK some sort of once only load variable is needed then - I thought 
>there might be a way around it.
>
>Out of curiosity, does anyone know if there a rule that governs about 
>whether Delphi/Windows fires the activate event for FormB again when 
>other forms over the top (FormC FormD) are closed?
>
>John
>
>-----Original Message-----
>From: Stacey Verner [mailto:stacey at cjntech.co.nz]
>Sent: Thursday, 5 October 2006 8:13 a.m.
>To: johnkbird at paradise.net.nz; NZ Borland Developers Group - Delphi List
>Subject: RE: [DUG] Forms Activate Design decision
>
>
>We use FormActivate for loading data as well, however we use a guarf 
>variable to make sure it happened only once.
>
>e.g.
>
>procedure TForm1.FormCreate(Sender: TObject);
>begin
>  FFormActivated := False;
>end;
>
>procedure TForm1.FormActivate(Sender: TObject);
>begin
>  if not FFormActivated then begin
>    FFormActivated := True;
>    // Do stuff
>  end;
>end;
>
>We actually have a FirstTimeFormActivate method to override for this 
>kind of thing in our base form class.
>
>Using FormActivate is great for triggering loading data because it 
>allow the form to be shown first, and then the data is loaded so the 
>users know something is going on. If you load data in FormCreate or 
>FormShow then the screen doesn't show untill all of the daya is loaded.
>
>Stacey
>
>
>-----Original Message-----
>From: delphi-bounces at ns3.123.co.nz 
>[mailto:delphi-bounces at ns3.123.co.nz]
>On Behalf Of John Bird
>Sent: Wednesday, 04 October 2006 17:53
>To: 'NZ Borland Developers Group - Delphi List'
>Subject: [DUG] Forms Activate Design decision
>
>A design question:
>
>FormA (Main form) open all the time.
>
>FormA opens FormB, and FormB filled with Data in On-activate event
>
>FormB may open FormC or FormD for further details
>
>When FormC or FormD is closed, sometimes FormB on-activate event is 
>fired again, sometimes not.
>
>I haven't figured yet what decides whether FormB activate event gets 
>fired again - as far as I can tell its not whether FormC or FormD is 
>modal or not. I would prefer either it wasn't fired, or I could tell 
>when it was going to be so as to exit the event, as sometimes the data 
>takes time to load again.
>
>For instance opening Rave Report rvSystem printing options always does 
>cause a form (eg FormB) to get re-activated when it closes.
>
>Is there a way I have missed to manage this?, or do I have to do some 
>housekeeping, eg maintain my own state variable somewhere:
>
>FormBLoadedData:Boolean
>
>And in the FormB activate event have something like
>
>	if FormBLoadedData=true then exit;
>	LoadtheData;
>	FormBLoadedData:=true;
>
>(this will prevent subsequent forms C and D reloading the data on FormB 
>when they close)
>
>And on the close event for FormB have
>
>	FormBLoadedData:=false;
>
>
>John
>
>
>_______________________________________________
>Delphi mailing list
>Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>__________ NOD32 1.1461 (20060329) Information __________
>
>This message was checked by NOD32 antivirus system. http://www.eset.com
>
>
>
>_______________________________________________
>Delphi mailing list
>Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>  
>



__________ NOD32 1.1461 (20060329) Information __________

This message was checked by NOD32 antivirus system. http://www.eset.com





More information about the Delphi mailing list