Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Where to place a 'very final' code for a window? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: [BUG?] CellBackgroundPaint not overriding default highlighting?
Next thread: SaveAsDialog BUG OS X


Win32 API Declares   -   Berg, Heath
  Where to place a 'very final' code for a window?   -   Stefan Pantke
   Re: Where to place a 'very final' code for a window?   -   Sven E Olsson
   Re: Where to place a 'very final' code for a window?   -   Phil M
   Re: Where to place a 'very final' code for a window?   -   Terry Ford
   Re: Where to place a 'very final' code for a window?   -   Mars Saxman
   Re: Where to place a 'very final' code for a window?   -   Charles Yeomans
   Re: Where to place a 'very final' code for a window?   -   Craig A. Finseth
   Re: Where to place a 'very final' code for a window?   -   Norman Palardy
   Re: Where to place a 'very final' code for a window?   -   Norman Palardy
   Re: Where to place a 'very final' code for a window?   -   Charles Yeomans
   Re: Where to place a 'very final' code for a window?   -   Stefan Pantke
   Re: Where to place a 'very final' code for a window?   -   Will Leshner
   Re: Where to place a 'very final' code for a window?   -   Norman Palardy
   Re: Where to place a 'very final' code for a window?   -   William Squires
   Re: Where to place a 'very final' code for a window?   -   Robert and Sigrid
   Re: Where to place a 'very final' code for a window?   -   Phil M
   Re: Where to place a 'very final' code for a window?   -   Robert and Sigrid
   Re: Where to place a 'very final' code for a window?   -   Norman Palardy
   Re: Where to place a 'very final' code for a window?   -   Stefan Pantke
   Re: Where to place a 'very final' code for a window?   -   Phil M
   Re: Where to place a 'very final' code for a window? (Correction)   -   Terry Ford

Where to place a 'very final' code for a window?
Date: 19.08.05 20:02 (Fri, 19 Aug 2005 21:02:49 +0200)
From: Stefan Pantke
I need to call some code at the very end of a window init:

- After the window and all controls have been constructed
- After all Open() events have been called

Why? Because certain controls save their state based on changed
control's state.

But what is the last event called? Needs to be cross platform.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:10 (Fri, 19 Aug 2005 21:10:24 +0200)
From: Sven E Olsson

On Aug 19, 2005, at 21:02, Stefan Pantke wrote:

> I need to call some code at the very end of a window init:
>
> - After the window and all controls have been constructed
> - After all Open() events have been called
>
> Why? Because certain controls save their state based on changed
> control's state.
>
> But what is the last event called? Needs to be cross platform.

Timer....

Sven E Olsson


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:14 (Fri, 19 Aug 2005 21:14:54 +0200)
From: Phil M
On Aug 19, 2005, at 9:02 PM, Stefan Pantke wrote:

> I need to call some code at the very end of a window init:
>
> - After the window and all controls have been constructed
> - After all Open() events have been called
>
> Why? Because certain controls save their state based on changed
> control's state.
>
> But what is the last event called? Needs to be cross platform.

Being that the Open event depends on implementation, you cannot
guarantee any "last" execution.

One method is that you can test for init values for the controls that
require setup. As each control goes through it's open even, set the
init value for that control. Then test the inits at the end of the
Open events... if all of them are true then process as you want.

The second option is to setup a Timer. The way that timers work, they
will not fire if there is other processing going on (initialization).
So if you set the timer to Mode 1 (single), it will fire after the
Open() events have completed.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:15 (Fri, 19 Aug 2005 12:15:50 -0700)
From: Terry Ford

On 19-Aug-05, at 12:10 PM, Sven E Olsson wrote:

>
> On Aug 19, 2005, at 21:02, Stefan Pantke wrote:
>
>> I need to call some code at the very end of a window init:
>>
>> - After the window and all controls have been constructed
>> - After all Open() events have been called
>>
>> Why? Because certain controls save their state based on changed
>> control's state.
>>
>> But what is the last event called? Needs to be cross platform.
>>
> Timer....

Set to mode1 at the end of the app.open event.
Code in the Timer.Action event.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:15 (Fri, 19 Aug 2005 12:15:56 -0700)
From: Mars Saxman

On Aug 19, 2005, at 12:02 PM, Stefan Pantke wrote:

> I need to call some code at the very end of a window init:
>
> - After the window and all controls have been constructed
> - After all Open() events have been called

This is what the window's Open event is for.

Mars Saxman
REAL Software
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:19 (Fri, 19 Aug 2005 15:19:56 -0400)
From: Charles Yeomans

On Aug 19, 2005, at 3:10 PM, Sven E Olsson wrote:

>
> On Aug 19, 2005, at 21:02, Stefan Pantke wrote:
>
>> I need to call some code at the very end of a window init:
>>
>> - After the window and all controls have been constructed
>> - After all Open() events have been called
>>
>> Why? Because certain controls save their state based on changed
>> control's state.
>>
>> But what is the last event called? Needs to be cross platform.
>
> Timer....

Yuck.

To get more control over the order of window initialization, use a
constructor.

Sub Constructor()

Super.Window //calls all open event handlers

//more initialization code here
End Sub

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:37 (Fri, 19 Aug 2005 14:37:56 -0500 (CDT))
From: Craig A. Finseth
...
> But what is the last event called? Needs to be cross platform.

Being that the Open event depends on implementation, you cannot
guarantee any "last" execution.
...

There are other approaches.

Have the Open event set a "not initted" flag.

Then, in, say, an Activate event for a control, check the flag. If
not initted, do the initialization and clear the flag. I do this for
PopUp controls a lot:

Property:
initted as Boolean

Open:
initted = false

PopUp.Activate:
if not initted then
...do initialization...
initted = true
end

You get the idea.

Craig
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:52 (Fri, 19 Aug 2005 13:52:36 -0600)
From: Norman Palardy

On Aug 19, 2005, at 1:02 PM, Stefan Pantke wrote:

> I need to call some code at the very end of a window init:
>
> - After the window and all controls have been constructed
> - After all Open() events have been called
>
> Why? Because certain controls save their state based on changed
> control's state.
>
> But what is the last event called? Needs to be cross platform.\

Create a subclass of a window and add a constructor

put code like this in the constructor

Super.Window() // this gets ALL open events to run

// now do my FINAL init stuff here

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 20:54 (Fri, 19 Aug 2005 13:54:31 -0600)
From: Norman Palardy

On Aug 19, 2005, at 1:19 PM, Charles Yeomans wrote:

> Yuck.
>
> To get more control over the order of window initialization, use a
> constructor.
>
> Sub Constructor()
>
> Super.Window //calls all open event handlers
>
> //more initialization code here
> End Sub
>
Glad to see I'm not the only one recommending this

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 19.08.05 21:37 (Fri, 19 Aug 2005 16:37:56 -0400)
From: Charles Yeomans

On Aug 19, 2005, at 3:54 PM, Norman Palardy wrote:

>
> On Aug 19, 2005, at 1:19 PM, Charles Yeomans wrote:
>
>> Yuck.
>>
>> To get more control over the order of window initialization, use a
>> constructor.
>>
>> Sub Constructor()
>>
>> Super.Window //calls all open event handlers
>>
>> //more initialization code here
>> End Sub
>>
> Glad to see I'm not the only one recommending this
>

Great minds think like.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 00:50 (Sat, 20 Aug 2005 01:50:45 +0200)
From: Stefan Pantke

Am 19.08.2005 um 21:52 schrieb Norman Palardy:

>
> On Aug 19, 2005, at 1:02 PM, Stefan Pantke wrote:
>
>> I need to call some code at the very end of a window init:
>>
>> - After the window and all controls have been constructed
>> - After all Open() events have been called
>>
>> Why? Because certain controls save their state based on changed
>> control's state.
>>
>> But what is the last event called? Needs to be cross platform.\
>>
> Create a subclass of a window and add a constructor
>
> put code like this in the constructor
>
> Super.Window() // this gets ALL open events to run
>
> // now do my FINAL init stuff here

Really? Don't the fire when the window gets really visible?

My window is a view for a model. I ask the view to load certain
data, which then passes the data to its model:

<<<
aProject = New ProjectWindow() // (1)
// aProject.Show() - even this doesn't show the window
// aProject.UpdateNow() - even this doesn't show the window
if ( nil <> aProject ) Then
dummyB = aProject.DoFileOpen( FolderItem( OpenRecentSampleEntry
(index).Tag() ) ) // (2)
Else
Beep()
End If
>>>

(1) constructs the window and (2) loads the data. I wonder,
if the Open() events for controls fire before or after
aProject.DoFileOpen() did its job.



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 00:59 (Fri, 19 Aug 2005 16:59:26 -0700)
From: Will Leshner

On Aug 19, 2005, at 4:50 PM, Stefan Pantke wrote:

> (1) constructs the window and (2) loads the data. I wonder,
> if the Open() events for controls fire before or after
> aProject.DoFileOpen() did its job.

I believe any control's Open event fires when you call super.Window.

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 01:21 (Fri, 19 Aug 2005 18:21:31 -0600)
From: Norman Palardy

On Aug 19, 2005, at 5:50 PM, Stefan Pantke wrote:

>>
>> Create a subclass of a window and add a constructor
>>
>> put code like this in the constructor
>>
>> Super.Window() // this gets ALL open events to run
>>
>> // now do my FINAL init stuff here
>
> Really? Don't the fire when the window gets really visible?
>
Really !

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 15:48 (Sat, 20 Aug 2005 09:48:12 -0500)
From: William Squires
I don't think there is one; I usually just put a short-period timer
(say Period = 50) on the window, and put the code there. I then enable
the timer at the time when I show the window. Not perfect, but it's at
least X-plat!
I suppose you could even subclass a window and make a New Event
EveryoneFired(), then - in the window's Open() event, instantiate a
timer from code, and let it fire your new event, though this is a lot
trickier than simply putting the timer there yourself.

1) Make a new class, say "MyEveryoneFiredWindow", and set its Super to
Window.
2) Add 2 New Events to it; Open() and EveryoneFired().
3) Make another new class, "MyNotificationTimer", and set its Super to
Timer
a) give this new class a protected property "fParent As Window"
b) give it a new method, "Sub Parent(Assigns w As Window)"

Sub Parent(Assigns w As Window)
fParent = w
End Sub

c) in its Action() event, put:

"fParent.Notify()"

4) In your new window subclass, make a new "Sub Notify()"

Sub Notify()
EveryoneFired
End Sub

5) Add a new protected property "fFireTimer As MyNotificationTimer"
6) In your new window class' Open() event, put:

Sub Open()
fFireTimer = New MyNotificationTimer()
fFireTimer.Parent = Self
fFireTimer.Mode = 1
Open
End Sub

Now, make a new Window, and set its Super to "MyEveryoneFiredWindow".
You should be able to do whatever you need in its new "EveryoneFired"
event!

On Aug 19, 2005, at 2:02 PM, Stefan Pantke wrote:

> I need to call some code at the very end of a window init:
>
> - After the window and all controls have been constructed
> - After all Open() events have been called
>
> Why? Because certain controls save their state based on changed
> control's state.
>
> But what is the last event called? Needs to be cross platform.
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
A compiler is a tool for turning source code into error messages;
generating machine language bytes is just a fortuitous by-product!

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 15:08 (Sat, 20 Aug 2005 16:08:41 +0200)
From: Robert and Sigrid
I agree with Charles and Norman, for these circumstanses you'd like
to use a constructor. However, I think it is not necessary to
subclass your window and add a constructor in that subclass (as
suggested by Norman) for those of us who used the timer trick in
existing projects.
In RB 5.5 one needs to create a method, and at the right of the
name field push the pop-up menu to reveal the "constructor/
destructor" menu. Choose 'Constructor' and the method will already
contain the Super.window call. Just add the code that you'd have in
the action event of the timer right after that, and take out the
timer and the line in the open event of the window that says
'timer.mode = 1' and away you go.
In RB2005 you'd have to do a bit more yourself (see RB feedback
system, feature request ID:oiyjezff), but it comes down to the same.
Just create a new method and call it 'Constructor' yourself, put the
Super.Window code as the first line in this method followed by the
code of the action event of the timer. Take out the timer and the
line in the open event of the window that says 'timer.mode = 1' and
you're all set.
Now obviously, Norman is right in that you might want to make a
subclass of a window, and put the constructor in it, so when you
create a new window you'd always use that and have the constructor
available.

Cheers,
Robert

On 19 Aug, 2005, at 23:07, Norman Palardy <npalardy@great-white-
software.com> wrote:

> On Aug 19, 2005, at 1:02 PM, Stefan Pantke wrote:
>
>> I need to call some code at the very end of a window init:
>>
>> - After the window and all controls have been constructed
>> - After all Open() events have been called
>>
>> Why? Because certain controls save their state based on changed
>> control's state.
>>
>> But what is the last event called? Needs to be cross platform.\
>>
> On Aug 19, 2005, at 1:19 PM, Charles Yeomans wrote:
>
>> Yuck.
>>
>> To get more control over the order of window initialization, use a
>> constructor.
>>
>> Sub Constructor()
>>
>> Super.Window //calls all open event handlers
>>
>> //more initialization code here
>> End Sub
>
> Create a subclass of a window and add a constructor
>
> put code like this in the constructor
>
> Super.Window() // this gets ALL open events to run
>
> // now do my FINAL init stuff here
>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 15:48 (Sat, 20 Aug 2005 16:48:07 +0200)
From: Phil M
On Aug 20, 2005, at 4:08 PM, Robert and Sigrid wrote:

> I agree with Charles and Norman, for these circumstanses you'd like to
> use a constructor. However, I think it is not necessary to subclass
> your window and add a constructor in that subclass (as suggested by
> Norman) for those of us who used the timer trick in existing projects.

The question is what happens with ContainerControls?

You do not need to call Super.Constructor, in fact it will give you a
compiler error if you try. So there is no way for you to control when
the Open events fire with ContainerControls... and I haven't tested to
see when they are handled, but I would guess they happen after the
Constructor completes.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 17:28 (Sat, 20 Aug 2005 18:28:05 +0200)
From: Robert and Sigrid
Dear Phil,

First of all no-one has ever mentioned to call Super.Constructor.
Instead we (Norman, Charles and myself) mentioned to call
Super.window in the constructor method, to ensure that all open event
handlers of the window and all the controls it contains are called
before the rest of the initiation code from the constructor runs.

Now I've quickly tested to see what answer could be given on your
specific question about the behaviour of ContainerControls in this
matter. The short is: it works both on ContainerControls that you
embed in a window in the IDE as well as those that you add via code.
The latter was created in the open event handler of the window
(ContainerControl1.EmbedWithin(Self,50,100)).

HTH
Robert
On 20 Aug, 2005, at 16:48, Phil M <<email address removed>> wrote:

> On Aug 20, 2005, at 4:08 PM, Robert and Sigrid wrote:
>
>> I agree with Charles and Norman, for these circumstanses you'd
>> like to
>> use a constructor. However, I think it is not necessary to subclass
>> your window and add a constructor in that subclass (as suggested by
>> Norman) for those of us who used the timer trick in existing
>> projects.
>>
> The question is what happens with ContainerControls?
>
> You do not need to call Super.Constructor, in fact it will give you a
> compiler error if you try. So there is no way for you to control when
> the Open events fire with ContainerControls... and I haven't tested to
> see when they are handled, but I would guess they happen after the
> Constructor completes.
>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 21:56 (Sat, 20 Aug 2005 14:56:10 -0600)
From: Norman Palardy

On Aug 20, 2005, at 8:08 AM, Robert and Sigrid wrote:

> I agree with Charles and Norman, for these circumstanses you'd like to
> use a constructor. However, I think it is not necessary to subclass
> your window and add a constructor in that subclass (as suggested by
> Norman) for those of us who used the timer trick in existing projects.

You're right ... just adding the constructor to a window would be
sufficient

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 22:03 (Sat, 20 Aug 2005 23:03:08 +0200)
From: Stefan Pantke

Am 20.08.2005 um 22:56 schrieb Norman Palardy:

>
> On Aug 20, 2005, at 8:08 AM, Robert and Sigrid wrote:
>
>> I agree with Charles and Norman, for these circumstanses you'd
>> like to use a constructor. However, I think it is not necessary to
>> subclass your window and add a constructor in that subclass (as
>> suggested by Norman) for those of us who used the timer trick in
>> existing projects.
>>
> You're right ... just adding the constructor to a window would be
> sufficient

Thanks to all! Meanwhile I fixed the problem.

In fact, I had a 'inited' property in the constructor, but there
were more going on under the hood. Thus, my fault.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Where to place a 'very final' code for a window?
Date: 20.08.05 22:13 (Sat, 20 Aug 2005 23:13:16 +0200)
From: Phil M
On Aug 20, 2005, at 6:28 PM, Robert and Sigrid wrote:

> First of all no-one has ever mentioned to call Super.Constructor.
> Instead we (Norman, Charles and myself) mentioned to call Super.window
> in the constructor method, to ensure that all open event handlers of
> the window and all the controls it contains are called before the rest
> of the initiation code from the constructor runs.

I was wrong about the syntax for the Window Constructor... sorry.
There are feature requests to make class names (old style constructors)
and Constructor methods interchangeable.

I just wanted to point out that for some reason ContainerControls do
not follow the same rules. It appears the ContainerControl.Constructor
does not seem to be required to initiate the events, and in my tests it
doesn't seem possible. So even though ContainerControl is a subclass
of Window, you cannot use the Super.Window trick suggested.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>