WinCalcFrameRect: Difference between revisions
Created page with "This function calculates a client rectangle from a frame rectangle, or a frame rectangle from a client rectangle. ==Syntax== WinCalcFrameRect(hwndFrame, prcl, fClient); ==..." |
|||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This function calculates a client rectangle from a frame rectangle, or a frame rectangle from a client rectangle. | This function calculates a client rectangle from a frame rectangle, or a frame rectangle from a client rectangle. | ||
==Syntax== | ==Syntax== | ||
WinCalcFrameRect(hwndFrame, prcl, fClient) | WinCalcFrameRect(hwndFrame, prcl, fClient) | ||
==Parameters== | ==Parameters== | ||
;hwndFrame (HWND) - input | ;hwndFrame ([[HWND]]) - input:Frame-window handle. | ||
:Frame-window handle. | ;prcl ([[PRECTL]]) - in/out:Window rectangle. | ||
:Note: The value of each field in this structure must be in the range -32 768 through 32 767. The data type [[WRECT]] can also be used, if supported by the language. | |||
;prcl (PRECTL) - in/out | ;fClient ([[BOOL]]) - input:Frame indicator. | ||
:Window rectangle. | :;TRUE:Frame rectangle provided | ||
:Note: The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT can also be used, if supported by the language. | :;FALSE:Client-area rectangle provided. | ||
;fClient (BOOL) - input | |||
:Frame indicator. | |||
:;TRUE | |||
:;FALSE | |||
==Returns== | ==Returns== | ||
; rc (BOOL) - returns | ; rc ([[BOOL]]) - returns | ||
:Rectangle-calculated indicator. | :Rectangle-calculated indicator. | ||
:;TRUE:Rectangle successfully calculated | |||
:;TRUE | :;FALSE:Error occurred, or the calculated rectangle is empty. | ||
:;FALSE | |||
==Errors== | ==Errors== | ||
Possible returns from WinGetLastError | Possible returns from WinGetLastError | ||
;PMERR_INVALID_HWND (0x1001) | ;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified. | ||
:An invalid window handle was specified. | |||
==Remarks== | ==Remarks== | ||
In order for WinCalcFrameRect to perform its calculations correctly, the window rectangle in '''prcl''' must be specified in screen coordinates. The [[WinMapWindowPoints]] function is called to make the conversion from client coordinates to screen coordinates, as shown in the example code. | |||
WinCalcFrameRect provides the size and position of the client area within the specified frame rectangle for the specified frame window, or conversely, the size and position of the frame window that would contain a client window of the specified size and position. | WinCalcFrameRect provides the size and position of the client area within the specified frame rectangle for the specified frame window, or conversely, the size and position of the frame window that would contain a client window of the specified size and position. | ||
WinCalcFrameRect sends a WM_CALCFRAMERECT message to the frame window. This enables a subclassed frame control to implement the calculation correctly. | WinCalcFrameRect sends a [[WM_CALCFRAMERECT]] message to the frame window. This enables a subclassed frame control to implement the calculation correctly. | ||
This function works if hwndFrame is hidden; hwndFrame should be hidden if it is required that the window shows a particular client rectangle when the window is first shown. | This function works if '''hwndFrame''' is hidden; '''hwndFrame''' should be hidden if it is required that the window shows a particular client rectangle when the window is first shown. | ||
==Example Code== | ==Example Code== | ||
Line 57: | Line 44: | ||
/* convert client boundary coordinates to screen coordinates */ | /* convert client boundary coordinates to screen coordinates */ | ||
WinMapWindowPoints(hwndClient, HWND_DESKTOP, (PPOINTL)&rclBoundary, | WinMapWindowPoints(hwndClient, HWND_DESKTOP, (PPOINTL)&rclBoundary, 2); | ||
/* calculate equivalent frame boundary from boundary data */ | /* calculate equivalent frame boundary from boundary data */ | ||
Line 77: | Line 63: | ||
==Related Functions== | ==Related Functions== | ||
* WinCreateFrameControls | * [[WinCreateFrameControls]] | ||
* WinCreateStdWindow | * [[WinCreateStdWindow]] | ||
* WinCreateWindow | * [[WinCreateWindow]] | ||
* WinDefWindowProc | * [[WinDefWindowProc]] | ||
* WinDestroyWindow | * [[WinDestroyWindow]] | ||
* WinQueryClassInfo | * [[WinQueryClassInfo]] | ||
* WinQueryClassName | * [[WinQueryClassName]] | ||
* WinRegisterClass | * [[WinRegisterClass]] | ||
* WinSubclassWindow | * [[WinSubclassWindow]] | ||
==Related Messages== | ==Related Messages== | ||
* WM_CALCFRAMERECT | * [[WM_CALCFRAMERECT ]] | ||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 15:21, 15 May 2025
This function calculates a client rectangle from a frame rectangle, or a frame rectangle from a client rectangle.
Syntax
WinCalcFrameRect(hwndFrame, prcl, fClient)
Parameters
- hwndFrame (HWND) - input
- Frame-window handle.
- prcl (PRECTL) - in/out
- Window rectangle.
- Note: The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT can also be used, if supported by the language.
- fClient (BOOL) - input
- Frame indicator.
- TRUE
- Frame rectangle provided
- FALSE
- Client-area rectangle provided.
Returns
- rc (BOOL) - returns
- Rectangle-calculated indicator.
- TRUE
- Rectangle successfully calculated
- FALSE
- Error occurred, or the calculated rectangle is empty.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
In order for WinCalcFrameRect to perform its calculations correctly, the window rectangle in prcl must be specified in screen coordinates. The WinMapWindowPoints function is called to make the conversion from client coordinates to screen coordinates, as shown in the example code.
WinCalcFrameRect provides the size and position of the client area within the specified frame rectangle for the specified frame window, or conversely, the size and position of the frame window that would contain a client window of the specified size and position.
WinCalcFrameRect sends a WM_CALCFRAMERECT message to the frame window. This enables a subclassed frame control to implement the calculation correctly.
This function works if hwndFrame is hidden; hwndFrame should be hidden if it is required that the window shows a particular client rectangle when the window is first shown.
Example Code
This example converts a client window's boundaries into screen coordinates and calls WinCalcFrameRect to calculate an equivalent frame rectangle size.
#define INCL_WINFRAMEMGR /* Window Frame Functions */ #define INCL_WINWINDOWMGR /* Window Manager Functions */ #include <os2.h> BOOL fSuccess; /* Success indicator */ HWND hwndClient; /* client window */ HWND hwndFrame; /* frame window */ RECTL rclBoundary; /* Boundary rectangle */ /* convert client boundary coordinates to screen coordinates */ WinMapWindowPoints(hwndClient, HWND_DESKTOP, (PPOINTL)&rclBoundary, 2); /* calculate equivalent frame boundary from boundary data */ fSuccess = WinCalcFrameRect(hwndFrame, &rclBoundary, FALSE);
#define INCL_WINFRAMEMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwndFrame; /* Frame-window handle. */ PRECTL prcl; /* Window rectangle. */ BOOL fClient; /* Frame indicator. */ BOOL rc; /* Rectangle-calculated indicator. */ rc = WinCalcFrameRect(hwndFrame, prcl, fClient);
Related Functions
- WinCreateFrameControls
- WinCreateStdWindow
- WinCreateWindow
- WinDefWindowProc
- WinDestroyWindow
- WinQueryClassInfo
- WinQueryClassName
- WinRegisterClass
- WinSubclassWindow