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

  1. /*---------------------------------------------------------------------
  2.    PMHELLO2.C -- OS/2 PM "Hello, world" Program -- Window Procedure #2
  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.      POINTL       ptl, aptlTextBox[TXTBOX_COUNT] ;
  17.  
  18.      switch (msg)
  19.           {
  20.           case WM_SIZE:
  21.                cxClient = SHORT1FROMMP (mp2) ;
  22.                cyClient = SHORT2FROMMP (mp2) ;
  23.                return 0 ;
  24.  
  25.           case WM_PAINT:
  26.                hps = WinBeginPaint (hwnd, NULL, NULL) ;
  27.                GpiErase (hps) ;
  28.  
  29.                GpiQueryTextBox (hps, lLen, szText, TXTBOX_COUNT, aptlTextBox) ;
  30.  
  31.                ptl.x = (cxClient - (aptlTextBox[TXTBOX_BOTTOMRIGHT].x -
  32.                                     aptlTextBox[TXTBOX_BOTTOMLEFT].x)) / 2 ;
  33.                ptl.y = (cyClient - (aptlTextBox[TXTBOX_TOPLEFT].y -
  34.                                     aptlTextBox[TXTBOX_BOTTOMLEFT].y)) / 2 ;
  35.  
  36.                GpiCharStringAt (hps, &ptl, lLen, szText) ;
  37.  
  38.                WinEndPaint (hps) ;
  39.                return 0 ;
  40.           }
  41.      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
  42.      }
  43.