Annotation of pmsdk/samples/petzold/chap05/star5.c, revision 1.1

1.1     ! root        1: /*---------------------------------
        !             2:    STAR5.C -- Draws 5-Pointed Star
        !             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 [] = "Star5" ;
        !            12:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
        !            13:                                  FCF_SIZEBORDER    | FCF_MINMAX  |
        !            14:                                  FCF_SHELLPOSITION | FCF_TASKLIST ;
        !            15:      HAB          hab ;
        !            16:      HMQ          hmq ;
        !            17:      HWND         hwndFrame, hwndClient ;
        !            18:      QMSG         qmsg ;
        !            19: 
        !            20:      hab = WinInitialize (0) ;
        !            21:      hmq = WinCreateMsgQueue (hab, 0) ;
        !            22: 
        !            23:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
        !            24: 
        !            25:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
        !            26:                                      &flFrameFlags, szClientClass, NULL,
        !            27:                                      0L, NULL, 0, &hwndClient) ;
        !            28: 
        !            29:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            30:           WinDispatchMsg (hab, &qmsg) ;
        !            31: 
        !            32:      WinDestroyWindow (hwndFrame) ;
        !            33:      WinDestroyMsgQueue (hmq) ;
        !            34:      WinTerminate (hab) ;
        !            35:      return 0 ;
        !            36:      }
        !            37: 
        !            38: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
        !            39:      {
        !            40:      static POINTL aptlStar[5] = {-59,-81, 0,100, 59,-81, -95,31, 95,31 } ;
        !            41:      static SHORT  cxClient, cyClient ;
        !            42:      HPS           hps ;
        !            43:      POINTL        aptl[5] ;
        !            44:      SHORT         sIndex ;
        !            45: 
        !            46:      switch (msg)
        !            47:          {
        !            48:           case WM_SIZE:
        !            49:                cxClient = SHORT1FROMMP (mp2) ;
        !            50:                cyClient = SHORT2FROMMP (mp2) ;
        !            51:                return 0 ;
        !            52: 
        !            53:           case WM_PAINT:
        !            54:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
        !            55:                GpiErase (hps) ;
        !            56: 
        !            57:                for (sIndex = 0 ; sIndex < 5 ; sIndex++)
        !            58:                     {
        !            59:                     aptl[sIndex].x = cxClient / 2 + cxClient *
        !            60:                                                  aptlStar[sIndex].x / 200 ;
        !            61:                     aptl[sIndex].y = cyClient / 2 + cyClient *
        !            62:                                                  aptlStar[sIndex].y / 200 ;
        !            63:                     }
        !            64:                GpiMove (hps, aptl + 4) ;
        !            65:                GpiPolyLine (hps, 5L, aptl) ;
        !            66: 
        !            67:                WinEndPaint (hps) ;
        !            68:                return 0 ;
        !            69:           }
        !            70:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !            71:      }

unix.superglobalmegacorp.com

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