Annotation of pmsdk/samples/petzold/chap02/welcome.c, revision 1.1.1.1

1.1       root        1: /*---------------------------------------------------------
                      2:    WELCOME.C -- A Program that Writes to its Client Window
                      3:   ---------------------------------------------------------*/
                      4: 
                      5: #include <os2.h>
                      6: 
                      7: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
                      8: 
                      9: int main (void)
                     10:      {
                     11:      static CHAR szClientClass [] = "Welcome" ;
                     12:      HAB         hab ;
                     13:      HMQ         hmq ;
                     14:      HWND        hwndFrame, hwndClient ;
                     15:      QMSG        qmsg ;
                     16:      ULONG       flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
                     17:      ULONG       flFrameStyle = WS_VISIBLE ;
                     18: 
                     19:      hab = WinInitialize (0) ;
                     20:      hmq = WinCreateMsgQueue (hab, 0) ;
                     21: 
                     22:      WinRegisterClass (
                     23:                     hab,                /* Anchor block handle             */
                     24:                     szClientClass,      /* Name of class being registered  */
                     25:                     ClientWndProc,      /* Window procedure for class      */
                     26:                     CS_SIZEREDRAW,      /* Class style                     */
                     27:                     0) ;                /* Extra bytes to reserve          */
                     28: 
                     29:      hwndFrame = WinCreateStdWindow (
                     30:                     HWND_DESKTOP,       /* Parent window handle            */
                     31:                     flFrameStyle,       /* Style of frame window           */
                     32:                     &flFrameFlags,      /* Pointer to control data         */
                     33:                     szClientClass,      /* Client window class name        */
                     34:                     "WELCOME Program",  /* Title bar text                  */
                     35:                     0L,                 /* Style of client window          */
                     36:                     NULL,               /* Module handle for resources     */
                     37:                     0,                  /* ID of resources                 */
                     38:                     &hwndClient) ;      /* Pointer to client window handle */
                     39: 
                     40:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     41:           WinDispatchMsg (hab, &qmsg) ;
                     42: 
                     43:      WinDestroyWindow (hwndFrame) ;
                     44:      WinDestroyMsgQueue (hmq) ;
                     45:      WinTerminate (hab) ;
                     46: 
                     47:      return 0 ;
                     48:      }
                     49: 
                     50: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     51:      {
                     52:      static CHAR szText [] = "Welcome to the OS/2 Presentation Manager" ;
                     53:      HPS         hps;
                     54:      RECTL       rcl ;
                     55: 
                     56:      switch (msg)
                     57:          {
                     58:           case WM_CREATE:
                     59:                DosBeep (261, 100) ;
                     60:                DosBeep (330, 100) ;
                     61:                DosBeep (392, 100) ;
                     62:                DosBeep (523, 500) ;
                     63:                return 0 ;
                     64: 
                     65:           case WM_PAINT:
                     66:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     67: 
                     68:                WinQueryWindowRect (hwnd, &rcl) ;
                     69: 
                     70:                WinDrawText (hps, -1, szText, &rcl,
                     71:                             CLR_NEUTRAL, CLR_BACKGROUND,
                     72:                             DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
                     73: 
                     74:                WinEndPaint (hps) ;
                     75:                return 0 ;
                     76: 
                     77:           case WM_DESTROY:
                     78:                DosBeep (523, 100) ;
                     79:                DosBeep (392, 100) ;
                     80:                DosBeep (330, 100) ;
                     81:                DosBeep (261, 500) ;
                     82:                return 0 ;
                     83:           }
                     84:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     85:      }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.