Kbase P112643: How to check if a window has another window on top?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  18/01/2006 |
|
Status: Unverified
GOAL:
How to check if a window has another window on top?
FACT(s) (Environment):
Windows
FIX:
When 4GL creates a window widget ( CREATE WINDOW statement ) the resulted handle points to the client region of the OS window object.
Thus, by checking the parent and the foremost window the application can determine if its window is the top window.
Here is the sample code:
DEF VAR hwndParent as INTEGER.
DEF VAR hwndTop AS INTEGER.
DEF VAR hwndCur as INTEGER.
hwndCur = {&WINDOW-NAME}:HWND.
RUN GetParent( hwndCur, OUTPUT hwndParent ).
RUN GetForegroundWindow( OUTPUT hwndTop ).
IF( hwndParent = hwndTop ) THEN
DO:
/* YES, my {&WINDOW-NAME} is the top window */
END.
PROCEDURE GetParent EXTERNAL "user32.dll" :
DEFINE INPUT PARAM hParent AS LONG.
DEFINE RETURN PARAM hRes AS LONG.
END PROCEDURE.
PROCEDURE GetForegroundWindow EXTERNAL "user32.dll" :
DEFINE RETURN PARAM hRes AS LONG.
END PROCEDURE.