Consultor Eletrônico



Kbase P122439: How to access the Windows Taskbar size and position?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   2/22/2007
Status: Unverified

GOAL:

How to access the Windows Taskbar size and position?

GOAL:

How to send the WIN32 API ABM_GETTASKBARPOS Message?

GOAL:

How to retrieve the dimensions of the bounding rectangle of the Windows Task bar?

GOAL:

How to determine whether the Windows Taskbar is in the TOP, LEFT, RIGHT or BOTTOM position?

GOAL:

How to call WIN32 API function: SHAppBarMessage?

FIX:


The following code send the the WIN32 API ABM_GETTASKBARPOS Message using the WIN32 API SHAppBarMessage function to retrieve the bounding rectangle of the Windows Task bar and calculate its length, width and orientation:
/*******************************************************************/
/* Procedure: HowToAccessTheWindowsTaskBarSizeAndPosition.p */
/* */
/* Description: Determine the Windows Taskbar dimensions and position. */
/*******************************************************************/
&GLOBAL-DEFINE ABM_GETTASKBARPOS 5
&GLOBAL-DEFINE ABE_LEFT 0
&GLOBAL-DEFINE ABE_TOP 1
&GLOBAL-DEFINE ABE_RIGHT 2
&GLOBAL-DEFINE ABE_BOTTOM 3
DEFINE VARIABLE pData AS MEMPTR NO-UNDO.
DEFINE VARIABLE iResult AS INTEGER NO-UNDO.
FUNCTION getTaskbarPosition RETURNS CHARACTER () FORWARD.
FUNCTION getTaskbarLength RETURNS INTEGER () FORWARD.
FUNCTION getTaskbarWidth RETURNS INTEGER () FORWARD.
SET-SIZE(pData) = 32.
RUN SHAppBarMessage(
INPUT {&ABM_GETTASKBARPOS},
INPUT pData,
OUTPUT iResult
).
MESSAGE
"Position:~t" getTaskbarPosition() "~n"
"Length:~t:" getTaskbarLength() "~n"
"Width:~t:" getTaskbarWidth() "~n"
VIEW-AS ALERT-BOX INFO BUTTONS OK.

PROCEDURE SHAppBarMessage EXTERNAL "shell32.dll":
DEFINE INPUT PARAMETER dwMessage AS LONG.
DEFINE INPUT PARAMETER pData AS MEMPTR.
DEFINE RETURN PARAMETER iReturn AS LONG.
END.

FUNCTION getTaskbarPosition RETURNS CHARACTER ():
CASE GET-LONG(pData,13):
WHEN {&ABE_BOTTOM} THEN RETURN "BOTTOM".
WHEN {&ABE_RIGHT } THEN RETURN "RIGHT".
WHEN {&ABE_LEFT} THEN RETURN "LEFT".
WHEN {&ABE_TOP} THEN RETURN "TOP".
END CASE.
END FUNCTION.
FUNCTION getTaskbarLength RETURNS INTEGER ():
RETURN GET-LONG(pData,25) - GET-LONG(pData,17).
END FUNCTION.
FUNCTION getTaskbarWidth RETURNS INTEGER ():
. RETURN GET-LONG(pData,29) - GET-LONG(pData,21).
END FUNCTION..