Jump to content

WinCreateFrameControls

From EDM2
Revision as of 09:45, 5 April 2025 by Ak120 (talk | contribs)

This function creates the standard frame controls for a specified window.

Syntax

WinCreateFrameControls(hwndFrame, pfcdata, pszTitle)

Parameters

hwndFrame (HWND) - input
Frame-window handle.
Becomes the parent and owner window of all the frame controls that are created:
HWND_DESKTOP - The desktop window
HWND_OBJECT - Object window
Other - Specified window.
pfcdata (PFRAMECDATA) - input
Frame-control data.
This includes a combination of frame creation flags (FCF_*), that specifies which frame controls are to be created. For further information, see
pszTitle (PSZ) - input
Title string.
This parameter contains a string that is displayed in the WC_TITLEBAR control only when FCF_TITLEBAR is specified in pfcdata.

Returns

rc (BOOL) - returns
Success indicator.
TRUE - Successful completion
FALSE - Error occurred.

Errors

Possible returns from WinGetLastError:

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.
PMERR_INVALID_FLAG (0x1019)
An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.

Remarks

This function is typically used when the standard frame controls are needed for use with a nonstandard window (such as a non WC_FRAME class).

All of the controls are created with the standard FID_* window identifiers; see

The controls are created but not formatted. Formatting must be done by setting the required positions. All controls are created with position and size set to zero and WS_VISIBLE is not set.

Example Code

This example creates frame controls (title bar, system menu, size border, and min/max buttons) for a button window created by WinCreateWindow. The new controls are owned by and children of the button window.

#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#define INCL_WINLISTBOXES       /* List Box definitions         */
#define INCL_WINFRAMEMGR        /* Frame Manager Functions      */
#include <os2.h>

HWND    hwnd;           /* cursor display window                */
ULONG flStyle;          /* window style                         */
USHORT ButtonId;        /* window id  (app supplied)            */
BOOL  fSuccess;         /* success indicator                    */
FRAMECDATA  pFcdata;    /* Frame-control data                   */
USHORT  usFrameId;      /* frame resource id (app supplied)     */


flStyle = WS_VISIBLE;                 /* create window visible  */

/* create button window (no frame controls) */
hwnd = WinCreateWindow(HWND_DESKTOP,  /* parent window          */
                       WC_BUTTON,    /* class name             */
                       "new button",  /* window text            */
                       flStyle,       /* window style           */
                       0, 0,          /* position (x,y)         */
                       200, 100,      /* size (width,height)    */
                       0L,            /* owner window           */
                       HWND_TOP,      /* sibling window         */
                       ButtonId,      /* window id              */
                       NULL,          /* control data           */
                       NULL);         /* presentation parms     */

/******************************
 * initialize frame structure *
 ******************************/
pFcdata.cb = sizeof(FRAMECDATA);  /* Length  */
/* Frame-creation flags  */
pFcdata.flCreateFlags = FCF_TITLEBAR |  FCF_SYSMENU |
                        FCF_SIZEBORDER | FCF_MINMAX;
pFcdata.hmodResources = 0L;       /* resource in EXE */
pFcdata.idResources = usFrameId;  /* resource id */

/* create frame controls; display 'button frame' on title bar */
fSuccess = WinCreateFrameControls(hwnd, &pFcdata, "button frame");

Related Functions