Kbase P122419: How to determine the Windows TaskBar length, width and position?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  22/02/2007 |
|
Status: Unverified
GOAL:
How to determine the Windows TaskBar length, width and position?
GOAL:
How to call WIN32 API function: FindWindow?
GOAL:
How to call WIN32 API function: GetWindowRect?
FACT(s) (Environment):
Windows
FIX:
References to Written Documentation:
Progress Solution:
P122439, "How to access the Windows TaskBar size and position?"
P122452, "How to get the Windows the Windows TaskBar Auto-hide and Always-On-Top properties?"
P122453, "How to hide and show the Windows TaskBar?"The following code invokes the WIN32 API function FindWindow and the WIN32 API function: GetWindowRect to access the Windows Taskbar length, width and position:
/*******************************************************************/
/* Procedure: WindowsTaskBarSizeAndPositionB.p */
/* */
/* Description: The WIN32 API GetWindowRect function returns a */
/* MEMPTR to a structure giving the Taskbar sides pixel distances */
/* from the top left corner of the window: */
/* Left = GET-LONG(lpRect, 1) */
/* Top = GET-LONG(lpRect, 5) */
/* Right = GET-LONG(lpRect, 9) . */
/* Bottom = GET-LONG(lpRect, 13) */
/*******************************************************************/
/* Variables used to invoke the WIN32 API function FindWindowA */
DEFINE VARIABLE lpClassName AS CHARACTER NO-UNDO.
DEFINE VARIABLE lpWindowName AS CHARACTER NO-UNDO.
DEFINE VARIABLE hWnd AS INTEGER NO-UNDO.
/* Variables used to invoke the WIN32 API function GetWindowRect */
DEFINE VARIABLE lpRect AS MEMPTR NO-UNDO.
DEFINE VARIABLE iResult AS INTEGER NO-UNDO.
/* User defined functions to extract the Taskbar information */
FUNCTION getTaskBarHeight RETURNS INTEGER (INPUT lpRect AS MEMPTR) FORWARD.
FUNCTION getTaskBarWidth RETURNS INTEGER (INPUT lpRect AS MEMPTR) FORWARD.
FUNCTION getTaskBarPosition RETURNS CHARACTER (INPUT lpRect AS MEMPTR) FORWARD.
RUN FindWindowA(
INPUT "shell_trayWnd",
INPUT "",
OUTPUT hWnd
).
SET-SIZE(lpRect) = 16.
RUN GetWindowRect(
INPUT hWnd,
OUTPUT lpRect,
OUTPUT iResult
).
MESSAGE
"Taskbar height:" "~t" getTaskBarHeight(lpRect) " pixels" "~n"
"Taskbar width:" "~t" getTaskBarWidth(lpRect) " pixels" "~n"
"Taskbar position:" "~t" getTaskBarPosition(lpRect)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
PROCEDURE FindWindowA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER lpClassName AS CHARACTER.
DEFINE INPUT PARAMETER lpWindowName AS CHARACTER.
DEFINE RETURN PARAMETER hWnd AS LONG.
END.
PROCEDURE GetWindowRect EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER hWnd AS LONG.
DEFINE OUTPUT PARAMETER lp.Rect AS MEMPTR.
DEFINE RETURN PARAMETER iResult AS LONG.
END.
FUNCTION getTaskBarPosition RETURNS CHARACTER (INPUT ipmlpRect AS MEMPTR).
IF GET-LONG(ipmlpRect, 1) LE 0 AND GET-LONG(ipmlpRect, 5) GT 0 THEN
RETURN "BOTTOM".
IF GET-LONG(ipmlpRect, 1) GT 0 THEN
RETURN "RIGHT".
IF GET-LONG(ipmlpRect, 13) - GET-LONG(ipmlpRect, 5) GE SESSION:HEIGHT-PIXELS THEN
RETURN "LEFT".
RETURN "TOP".
END FUNCTION.
FUNCTION getTaskBarHeight RETURNS INTEGER (INPUT ipmlpRect AS MEMPTR).
RETURN GET-LONG(lpRect, 13) - GET-LONG(lpRect, 5).
END FUNCTION.
FUNCTION getTaskBarWidth RETURNS INTEGER (INPUT ipmlpRect AS MEMPTR).
RETURN GET-LONG(lpRect, 9) - GET-LONG(lpRect, 1).
END FUNCTION..