Phenomenon
If the WindowState property of a Window is set to Normal! the order of the Open and Activate events is in this order:
-
Open
-
Activate
But if the WindowState property is changed to Maximized! then the order of the events is as follows:
-
Open (event starts)
-
Activate
-
Open (event ends)
Scenario
WindowState set as Normal!:
-
Create a Window with it's WindowState property set as Normal!
-
Open the Window using either one of these functions: Open, OpenWithParm, OpenSheet, OpenSheetWithParm.
-
The order of the Open and Activate events gets triggered as follows:
-
Open
-
Activate
-
WindowState set as Maximized!:
-
Create a Window with it's WindowState property set as Maximized!
-
Open the Window using either one of these functions: Open, OpenWithParm, OpenSheet, OpenSheetWithParm.
-
The order of the Open and Activate events gets triggered as follows:
-
Open (event starts)
-
Activate
-
Open (event ends)
-
Cause
Event trigger order may change from version to version of PowerBuilder. Also, events can trigger multiple times one after another (in example: {Open, Activate, Open} or {Open, Activate, Open, Activate}, etc...)
Workaround
-
Add an instance variable (ie: ib_open_completed).
-
Change your activate code to ... IF ib_open_completed = TRUE THEN ... do your code.
-
Add a ue_postopen user event & POST that from the Open event.
-
In the ue_postopen event, set the ib_open_completed = TRUE.
This should enable you to really control the order in which your code is triggered.
Notes: Changing the WindowState property
Do not change the WindowState Property in the Open event of a window opened as a sheet. Doing so might result in duplicate controls on the title bar. You can change the property in other scripts once the window is opened.