Jump to content

WinCalcFrameRect

From EDM2

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

Related Messages

  • WM_CALCFRAMERECT