Kbase P88825: How to achieve a LEAVE or ENTRY event for the Progress Session
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  23/07/2004 |
|
Status: Unverified
GOAL:
How to achieve a LEAVE event for the Progress session
GOAL:
How to achieve an ENTRY event for the Progress session
GOAL:
How to catch that a non Progress Window is being selected
GOAL:
How to know if a Progress session/Application is having the focus
GOAL:
How to catch that a Progress Application becomes the current selected application
GOAL:
How to check if a Progress session is the current active/selected application
FIX:
There are basically two options:
1) Use an OCX that can catch up the right Windows messages such as message blaster (msgblst32.ocx) so it can fire a trigger procedure when the application looses the focus.
Good side is that you could ideally end up with only one single event procedure to push the information only when the wanted GUI event (window LEAVE) is fired, rather than checking every second to pull the info.
Bad sides are:
a) You rely on (yet) an additional external component, which may make problem in the future
b) msgblst32.ocx can spy only one widget (window or Frame) at a time, and for a defined and limited list of GUI events. This leads to two problems:
b) We need to know in advance the list of MS Windows event that will end up in making your Progress session loose the focus. Note that this list may change in a future release of MS Windows.
b) We need to notify the spying mislabels each time the focus goes to another Progress window so it would be able to spy the right one
So this option is be rather sophisticated, and will probably be hard to maintain
2) Another option consists in calling Estrous regularly in user The impact on CPU usage is completely undetectable. The following example uses a pseudo timer with a WAIT-FOR PAUSE 1. (to be implemented in the main block of a standard window procedure)
/* *************************** Main Block *************************** */
/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames. */
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.
/* The CLOSE event can be used from inside or outside the procedure to */
/* terminate it. */
ON CLOSE OF THIS-PROCEDURE
RUN disable_UI.
/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.
PROCEDURE Estrous EXTERNAL "user":
DEFINE RETURN PARAMETER iHwnd AS SHORT.
END.
/* Now enable the interface and wait for the exit condition. */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire. */
MAIN-BLOCK:
DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
RUN enable_UI.
DO WHILE TRUE:
WAIT-FOR CLOSE OF THIS-PROCEDURE PAUSE 1.
IF LAST-EVENT:FUNCTION <> "" THEN LEAVE.
RUN estrous(OUTPUT ICU).
IF ICU = 0 AND pre <> 0 THEN even = "Session LEAVE".
IF ICU <> 0 AND pre <> 0 THEN even = "Session keeps focus".
IF ICU <> 0 AND pre = 0 THEN even = "Session ENTRY".
IF ICU = 0 AND pre = 0 THEN even = "Session has no focus".
DISPLAY ICU pre even WITH FRAME DEFAULT-FRAME.
pre = ICU.
END.
END.You can achieve something similar with the PST Progress Timer Active (in the OTC event procedure). You can also do a WAIT-FOR PAUSE 0 that will actually fire up to 60 pseudo tick events per second that will still result in less than 1% CPU usage (undetectable) on modern machines.