Phenomenon:


If the WindowState property of a Window is set to Normal! the order of the Open and Activate events is in this order:

  1. Open
  2. Activate

But if the WindowState property is changed to Maximized! then the order of the events is as follows:

  1. Open (event starts)
    1. ​Activate
  2. Open (event ends)

 


Scenario:


WindowState set as Normal!:

  1. Create a Window with it's WindowState property set as Normal!
  2. Open the Window using either one of these functions: Open, OpenWithParm, OpenSheet, OpenSheetWithParm.
  3. The order of the Open and Activate events gets triggered as follows:
    1. Open
    2. Activate

 

WindowState set as Maximized!:

  1. Create a Window with it's WindowState property set as Maximized!
  2. Open the Window using either one of these functions: Open, OpenWithParmOpenSheetOpenSheetWithParm.
  3. The order of the Open and Activate events gets triggered as follows:
    1. Open (event starts)
      1. Activate
    2. 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:


  1. Add an instance variable (ie: ib_open_completed).
  2. Change your activate code to ... IF ib_open_completed = TRUE THEN ... do your code.
  3. Add a ue_postopen user event & POST that from the Open event.
  4. 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.

  • Up
    0
  • Down
    1