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");


[Back] [Next]