This example calls WinOpenWindowDC to open a device context for a window, the handle to which is then used to associate a presentation space with the window.

#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#define INCL_GPICONTROL         /* Gpi Control Functions        */
#include <os2.h>

HWND  hwnd;             /* window handle                        */
HPS    hps;             /* presentation-space handle            */
SIZEL pagesize={0L,0L}; /* Presentation page size               */
HAB   hab;              /* Anchor-block handle                  */
HDC   hdc;              /* device-context handle                */

case WM_CREATE:                    /* Window just created       */

   hdc = WinOpenWindowDC(hwnd);   /* Open window device context */

   hps = GpiCreatePS(hab,               /* Create GPI PS and */
                     hdc,               /* associate with DC */
                     &pagesize,         /* default size */
                     PU_PELS |          /* pixel units */
                     GPIF_LONG |        /* 4-byte coordinates */
                     GPIA_ASSOC);       /* associate with device */


[Back] [Next]