Problem:
The demonstration attached uses Dialog system to simply create a GUI application and retrieve the handle of its Window.
This application can be modified and will work as soon as you have the handle ( HWND ) of a GUI Window
i.e. you can Set a Timer or|and Set Hook Procedures assuming that you have Window Handles
--> The program detailed below could be a generic program which manages Timeouts on more GUI applications ...
Resolution:
This KB here contains 2 demonstrations i.e.: 2 .ZIP files.
The 2 .ZIP files contain a Dialog System Application (DS) .... which is a convenient way to create a GUI Window
====
DEMO 1:
...........
The .ZIP file named DSWindowtimeout.zip is the sample demonstration:
1) in the SCREENSET-INITIALIZED event, set at the GlobalL Dialog Level,
the handle of the Window is retrieved thru the DS function MOVE-OBJECT-HANDLE,
the variable EXIT-FLAG is set to 9 DS RETC to come back to the COBOL program managing the screenset
2) The Cobol Program
Sets a Timer on the Window with the MS API SetTimer
3) Every time the screenset returns to the COBOL program,
The MS API GetMessageTime is used the return the 'MessageTime' of the last message received by the Window
4) Periodically, the Callback function activated by the Timer
uses the MS API GetMessageTime to retrieve the 'MessageTime' of the last message received by the Window
If the difference between the 'MessageTime'
retrieved in step 3)
and the one retrieved in step 4)
is greater than the MAXIMUM inactivity delay defined for the window,
the process is simply stopped by a Stop Run
Rmq:
-The MS API GetMessageTime used in Step 3) could be used in whatever program called by DS ( CALLOUT, OCX, ActiveX )
Then the variable used should only be defined as EXTERNAL
( 01 gmtDLONG LONG IS EXTERNAL. )
so the callback function of the Timer is aware of the latest content of gmtDLONG
- This demonstration retrieves the 'MessageTime' of the last message received by the Window in a COBOL program i.e. if the Window was busy without coming back to the|Any [Cobol] program, the 'MAXIMUM inactivity delay' on the Window could occur and the process being stopped when it shouldn't be
====
DEMO 2:
...........
That's why we have a more complicated demo in the .ZIP file DSapplStopTimeoutHOOK.zip
1) in the SCREENSET-INITIALIZED event, set at the GlobalL Dialog Level,
the handle of the Window is retrieved thru the DS function MOVE-OBJECT-HANDLE,
the variable EXIT-FLAG is set to 9 DS RETC to come back to the COBOL program managing the screenset
2) The Cobol Program
-Sets a Timer on the Window with the MS API SetTimer
-Sets a HOOK function with the MS API SetWindowsHookEx & parameter
WH_GETMESSAGE
( Installs a hook procedure that monitors messages posted to a message queue. )
The "hook procedure" which is a CALLBACK function, is invoked when whatever message occurs on the Window;
It uses the MS API GetMessageTime to return the 'MessageTime' of the last message received by the Window
3) Periodically, the Callback function activated by the Timer
uses the MS API GetMessageTime to retrieve the 'MessageTime' of the last message received by the Window
If the difference between the 'MessageTime'
retrieved in step 2) "hook procedure" CALLBACK function
and the one retrieved in step 3)
is greater than the MAXIMUM inactivity delay defined for the window,
the process is simply stopped by a Stop Run
====




