You create a container by using the WC_CONTAINER window class name in the ClassName parameter of WinCreateWindow. Before you create the container, you can create a frame window as a parent. If you create the frame window, it sizes the container to fill its work area. The following sample code shows the code to create both the frame and the container:

HAB     hab;
HWND    hPopupMenu;
HWND    hFrameWnd, hCnrWnd;   /* Frame and Container window handles */
PFNWP   SysWndProc;

INT main (VOID)
{
    HMQ         hmq;
    FRAMECDATA  fcd;
    QMSG        qmsg;

    if (!(hab = WinInitialize(0)))
      return FALSE;

    if (!(hmq = WinCreateMsgQueue(hab, 0)))
      return FALSE;

/***********************************************************************/
/*  Set up the frame control data for the frame window.                */
/***********************************************************************/
    fcd.cb = sizeof(FRAMECDATA);
    fcd.flCreateFlags = FCF_TITLEBAR      |
                        FCF_SYSMENU       |
                        FCF_SIZEBORDER    |
                        FCF_SHELLPOSITION |
                        FCF_MINMAX        |
                        FCF_TASKLIST;
    fcd.hmodResources = NULLHANDLE;
    fcd.idResources = 0;

/***********************************************************************/
/*  Create the frame to hold the container control.                    */
/***********************************************************************/
    hFrameWnd = WinCreateWindow(HWND_DESKTOP,
                                WC_FRAME,
                                "Phone Book",
                                0, 0, 0, 0, 0,
                                NULLHANDLE,
                                HWND_TOP,
                                0,
                                &fcd,
                                NULL);

/***********************************************************************/
/*  Verify that the frame was created; otherwise, stop.                */
/***********************************************************************/
    if (!hFrameWnd)
      return FALSE;

/***********************************************************************/
/*  Set an icon for the frame window.                                  */
/***********************************************************************/
    WinSendMsg(hFrameWnd,
               WM_SETICON,
               (MPARAM)WinQuerySysPointer(HWND_DESKTOP,
                                          SPTR_FOLDER,
                                          FALSE),
               NULL);

/***********************************************************************/
/*  Create the container.                                              */
/***********************************************************************/
    hCnrWnd = WinCreateWindow(hFrameWnd,
                              WC_CONTAINER,
                              NULL,
                              CCS_AUTOPOSITION |
                              CCS_READONLY     |
                              CCS_SINGLESEL,
                              0, 0, 0, 0,
                              hFrameWnd,
                              HWND_BOTTOM,
                              FID_CLIENT,
                              NULL,
                              NULL);

The container is created with a default set of control data, which can be changed using the CM_SETCNRINFO message.


[Back] [Next]