Kbase P160825: 4GL/ABL: How to calculate the WIDTH in PIXELS of the BORDER of a Progress / OpenEdge Window at runti
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  27/02/2010 |
|
Status: Unverified
GOAL:
4GL/ABL: How to calculate the WIDTH in PIXELS of the BORDER of a Progress / OpenEdge Window at runtime?
GOAL:
How to get the WIDTH in PIXELS of the Active Title Bar of a Progress / OpenEdge Window at runtime?
GOAL:
How to calculate the HEIGHT and WIDTH in PIXELS of the Client Area of a Progress / OpenEdge Window in pixels at runtime?
GOAL:
How to calculate the HEIGHT and WIDTH in PIXELS of the Total Area of a Progress / OpenEdge Window in pixels at runtime?
SYMPTOM(s):
How to calculate a 4GL/ABL Windows BORDER and Active Title Bar dimensions using the FindWindowA WIN API function?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)
FIX:
1. Create a new Window using the AppBuilder.
2. Create a new Procedure procedure named WinApiCalls and paste the following code AFTER its END PROCEDURE. statement. The WinApiCalls procedure is a place holder for the WIN32 EXTERNAL API function calls. In the AppBuilder design mode, the body of this procedure will look like this:
/*------------------------------------------------------------------------------
Purpose: Place procedure holder for EXTERNAL WIN API function calls
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
END PROCEDURE.
PROCEDURE FindWindowA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intClassName AS LONG.
DEFINE INPUT PARAMETER chrCaption AS CHARACTER.
DEFINE RETURN PARAMETER intHandle AS LONG.
END PROCEDURE.
PROCEDURE GetWindowRect EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER hWnd AS LONG.
DEFINE OUTPUT PARAMETER lpRect AS MEMPTR.
DEFINE RETURN PARAMETER iResult AS LONG.
END.
3. Drop a BUTTON on the Window and put the following code behind its CHOOSE event trigger. In the AppBuilder design mode, the body of this trigger will look like this:
DO:
DEFINE VARIABLE iHwnd AS INTEGER NO-UNDO.
DEFINE VARIABLE lpRect AS MEMPTR NO-UNDO.
DEFINE VARIABLE iResult AS INTEGER NO-UNDO.
DEFINE VARIABLE iWindowAreaWidth AS INTEGER NO-UNDO.
DEFINE VARIABLE iWindowAreaHeight AS INTEGER NO-UNDO.
DEFINE VARIABLE iClientAreaWidth AS INTEGER NO-UNDO.
DEFINE VARIABLE iClientAreaHeight AS INTEGER NO-UNDO.
DEFINE VARIABLE iWindowsBorderWidth AS INTEGER NO-UNDO.
DEFINE VARIABLE iWindowsTitleBarWidth AS INTEGER NO-UNDO.
RUN FindWindowA(
INPUT 0,
INPUT CURRENT-WINDOW:TITLE,
OUTPUT iHwnd
).
SET-SIZE(lpRect) = 16.
RUN GetWindowRect(
INPUT iHwnd,
OUTPUT lpRect,
OUTPUT iResult
).
ASSIGN
iWindowAreaWidth = GET-LONG(lpRect, 9) - GET-LONG(lpRect, 1)
iWindowAreaHeight = GET-LONG(lpRect, 13) - GET-LONG(lpRect, 5)
iClientAreaWidth = CURRENT-WINDOW:WIDTH-PIXELS
iClientAreaHeight = CURRENT-WINDOW:HEIGHT-PIXELS
iWindowsBorderWidth = (iWindowAreaWidth - iClientAreaWidth) / 2
iWindowsTitleBarWidth = iWindowAreaHeight - iClientAreaHeight - 2 * iWindowsBorderWidth.TRONG>
MESSAGE
"Window Area Width:~t" iWindowAreaWidth "~n"
"Window Area Height:~t" iWindowAreaHeight "~n"
"Client Area Width:~t~t" iClientAreaWidth "~n"
"Client Area Height:~t~t" iClientAreaHeight "~n"
"Border Width:~t~t" iWindowsBorderWidth "~n"
"Active Title Bar Width:~t" iWindowsTitleBarWidth
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
4. Save and Run the Window.
5. Click on the BUTTON to see the above mentioned dimensions displayed by the MESSAGE statement..