home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ENV719.ZIP / PMHELLO3.C < prev    next >
C/C++ Source or Header  |  1988-07-18  |  2KB  |  49 lines

  1. /*---------------------------------------------------------------------
  2.    PMHELLO3.C -- OS/2 PM "Hello, world" Program -- Window Procedure #3
  3.                  (c) 1988, Ziff Communications Company
  4.                  PC Magazine * Charles Petzold, 7/88
  5.   ---------------------------------------------------------------------*/
  6.  
  7. #define INCL_GPI
  8. #include <os2.h>
  9.  
  10. MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  11.      {
  12.      static CHAR  szText[] = "Hello, world" ;
  13.      static LONG  lLen = sizeof szText - 1 ;
  14.      static SHORT cxClient, cyClient ;
  15.      HPS          hps ;
  16.      GRADIENTL    gradl ;
  17.      POINTL       ptl, aptlTextBox[TXTBOX_COUNT] ;
  18.  
  19.      switch (msg)
  20.           {
  21.           case WM_SIZE:
  22.                cxClient = SHORT1FROMMP (mp2) ;
  23.                cyClient = SHORT2FROMMP (mp2) ;
  24.                return 0 ;
  25.  
  26.           case WM_PAINT:
  27.                hps = WinBeginPaint (hwnd, NULL, NULL) ;
  28.                GpiErase (hps) ;
  29.  
  30.                gradl.x = cxClient ;
  31.                gradl.y = cyClient ;
  32.                GpiSetCharAngle (hps, &gradl) ;
  33.                GpiSetCharMode (hps, CM_MODE3) ;
  34.  
  35.                GpiQueryTextBox (hps, lLen, szText, TXTBOX_COUNT, aptlTextBox) ;
  36.  
  37.                ptl.x = (cxClient - (aptlTextBox[TXTBOX_BOTTOMRIGHT].x -
  38.                                     aptlTextBox[TXTBOX_TOPLEFT].x)) / 2 ;
  39.                ptl.y = (cyClient - (aptlTextBox[TXTBOX_TOPRIGHT].y -
  40.                                     aptlTextBox[TXTBOX_BOTTOMLEFT].y)) / 2 ;
  41.  
  42.                GpiCharStringAt (hps, &ptl, lLen, szText) ;
  43.  
  44.                WinEndPaint (hps) ;
  45.                return 0 ;
  46.           }
  47.      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
  48.      }
  49.