Annotation of pmsdk/samples/petzold/chap03/welcome2.c, revision 1.1.1.1

1.1       root        1: /*------------------------------------------------------------
                      2:    WELCOME2.C -- A Program that Creates Two Top-Level Windows
                      3:   ------------------------------------------------------------*/
                      4: 
                      5: #include <os2.h>
                      6: #include <stddef.h>
                      7: 
                      8: MRESULT EXPENTRY Client1WndProc (HWND, USHORT, MPARAM, MPARAM) ;
                      9: MRESULT EXPENTRY Client2WndProc (HWND, USHORT, MPARAM, MPARAM) ;
                     10: 
                     11: int main (void)
                     12:      {
                     13:      static CHAR szClientClass1 [] = "Welcome1",                 
                     14:                  szClientClass2 [] = "Welcome2" ;
                     15:      HAB         hab ;
                     16:      HMQ         hmq ;
                     17:      HWND        hwndFrame1, hwndFrame2, hwndClient1, hwndClient2 ;
                     18:      QMSG        qmsg ;
                     19:      ULONG       flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
                     20:      ULONG       flFrameStyle = WS_VISIBLE ;
                     21: 
                     22:      hab = WinInitialize (0) ;
                     23:      hmq = WinCreateMsgQueue (hab, 0) ;
                     24: 
                     25:      WinRegisterClass (
                     26:                     hab,                /* Anchor block handle             */
                     27:                    szClientClass1,     /* Name of class being registered  */
                     28:                     Client1WndProc,     /* Window procedure for class      */
                     29:                     CS_SIZEREDRAW,      /* Class style                     */
                     30:                     0) ;                /* Extra bytes to reserve          */
                     31: 
                     32:      WinRegisterClass (
                     33:                     hab,                /* Anchor block handle             */
                     34:                    szClientClass2,     /* Name of class being registered  */
                     35:                     Client2WndProc,     /* Window procedure for class      */
                     36:                     CS_SIZEREDRAW,      /* Class style                     */
                     37:                     0) ;                /* Extra bytes to reserve          */
                     38: 
                     39:      hwndFrame1 = WinCreateStdWindow (
                     40:                     HWND_DESKTOP,       /* Parent window handle            */
                     41:                     flFrameStyle,       /* Style of frame window           */
                     42:                    &flFrameFlags,      /* Pointer to control data         */
                     43:                    szClientClass1,     /* Client window class name        */
                     44:                     "Window No. 1",     /* Title bar text                  */
                     45:                     0L,                 /* Style of client window          */
                     46:                     NULL,               /* Module handle for resources     */
                     47:                     0,                  /* ID of resources                 */
                     48:                     &hwndClient1) ;     /* Pointer to client window handle */
                     49: 
                     50:      hwndFrame2 = WinCreateStdWindow (
                     51:                     HWND_DESKTOP,       /* Parent window handle            */
                     52:                     flFrameStyle,       /* Style of frame window           */
                     53:                    &flFrameFlags,      /* Pointer to control data         */
                     54:                    szClientClass2,     /* Client window class name        */
                     55:                     "Window No. 2",     /* Title bar text                  */
                     56:                     0L,                 /* Style of client window          */
                     57:                     NULL,               /* Module handle for resources     */
                     58:                     0,                  /* ID of resources                 */
                     59:                     &hwndClient2) ;     /* Pointer to client window handle */
                     60: 
                     61:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     62:           WinDispatchMsg (hab, &qmsg) ;
                     63: 
                     64:      WinDestroyWindow (hwndFrame1) ;
                     65:      WinDestroyWindow (hwndFrame2) ;
                     66:      WinDestroyMsgQueue (hmq) ;
                     67:      WinTerminate (hab) ;
                     68: 
                     69:      return 0 ;
                     70:      }
                     71: 
                     72: MRESULT EXPENTRY Client1WndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     73:      {
                     74:      static CHAR szText [] = "Welcome to Window No. 1" ;
                     75:      HPS         hps ;
                     76:      RECTL       rcl ;
                     77: 
                     78:      switch (msg)
                     79:           {
                     80:           case WM_PAINT:
                     81:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     82: 
                     83:                WinQueryWindowRect (hwnd, &rcl) ;
                     84: 
                     85:                WinDrawText (hps, -1, szText, &rcl,
                     86:                             CLR_NEUTRAL, CLR_BACKGROUND,
                     87:                             DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
                     88: 
                     89:                WinEndPaint (hps) ;
                     90:                return 0 ;
                     91:           }
                     92:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     93:      }
                     94: 
                     95: MRESULT EXPENTRY Client2WndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     96:      {
                     97:      static CHAR szText [] = "Welcome to Window No. 2" ;
                     98:      HPS         hps ;
                     99:      RECTL       rcl ;
                    100: 
                    101:      switch (msg)
                    102:           {
                    103:           case WM_PAINT:
                    104:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                    105: 
                    106:                WinQueryWindowRect (hwnd, &rcl) ;
                    107: 
                    108:                WinDrawText (hps, -1, szText, &rcl,
                    109:                             CLR_NEUTRAL, CLR_BACKGROUND,
                    110:                             DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
                    111: 
                    112:                WinEndPaint (hps) ;
                    113:                return 0 ;
                    114: 
                    115:           case WM_CLOSE:
                    116:                return 0 ;
                    117:           }
                    118:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                    119:      }

unix.superglobalmegacorp.com

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