Annotation of pmsdk/samples/petzold/chap06/web.c, revision 1.1

1.1     ! root        1: /*--------------------------------------
        !             2:    WEB.C -- Mouse Movement Demo Program 
        !             3:   --------------------------------------*/
        !             4: 
        !             5: #define INCL_WIN
        !             6: #define INCL_GPI
        !             7: 
        !             8: #include <os2.h>
        !             9: #include <stddef.h>
        !            10: 
        !            11: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
        !            12: 
        !            13: int main (void)
        !            14:      {
        !            15:      static CHAR szClientClass [] = "Web" ;
        !            16:      HAB         hab ;
        !            17:      HMQ         hmq ;
        !            18:      HWND        hwndFrame, hwndClient ;
        !            19:      QMSG        qmsg ;
        !            20:      ULONG       flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
        !            21:      ULONG       flFrameStyle = WS_VISIBLE ;
        !            22: 
        !            23:      hab = WinInitialize (0) ;
        !            24:      hmq = WinCreateMsgQueue (hab, 0) ;
        !            25: 
        !            26:      WinRegisterClass (hab, szClientClass, ClientWndProc,
        !            27:                                           CS_SIZEREDRAW | CS_SYNCPAINT, 0) ;
        !            28: 
        !            29:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle,
        !            30:                                      &flFrameFlags, szClientClass,
        !            31:                                      "Mouse Movement Demo",
        !            32:                                     0L, NULL, 0, &hwndClient) ;
        !            33: 
        !            34:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            35:           WinDispatchMsg (hab, &qmsg) ;
        !            36: 
        !            37:      WinDestroyWindow (hwndFrame) ;
        !            38:      WinDestroyMsgQueue (hmq) ;
        !            39:      WinTerminate (hab) ;
        !            40:      
        !            41:      return 0 ;
        !            42:      }
        !            43: 
        !            44: VOID DrawWeb (HPS hps, POINTL *pptlPointerPos, POINTL *pptlClient)
        !            45:      {
        !            46:      POINTL ptl ;
        !            47: 
        !            48:           /*--------------------------------------
        !            49:              Lower Left to Pointer to Upper Right
        !            50:             --------------------------------------*/
        !            51: 
        !            52:      ptl.x = 0 ;
        !            53:      ptl.y = 0 ;
        !            54:      GpiMove (hps, &ptl) ;
        !            55:      GpiLine (hps, pptlPointerPos) ;
        !            56:      GpiLine (hps, pptlClient) ;
        !            57: 
        !            58:           /*--------------------------------------
        !            59:              Upper Left to Pointer to Lower Right
        !            60:             --------------------------------------*/
        !            61: 
        !            62:      ptl.x = 0 ;
        !            63:      ptl.y = pptlClient->y ;
        !            64: 
        !            65:      GpiMove (hps, &ptl) ;
        !            66:      GpiLine (hps, pptlPointerPos) ;
        !            67: 
        !            68:      ptl.x = pptlClient->x ;
        !            69:      ptl.y = 0 ;
        !            70: 
        !            71:      GpiLine (hps, &ptl) ;
        !            72: 
        !            73:           /*-----------------------------------------
        !            74:              Lower Middle to Pointer to Upper Middle
        !            75:             -----------------------------------------*/
        !            76: 
        !            77:      ptl.x = pptlClient->x / 2 ;
        !            78:      ptl.y = 0 ;
        !            79: 
        !            80:      GpiMove (hps, &ptl) ;
        !            81:      GpiLine (hps, pptlPointerPos) ;
        !            82: 
        !            83:      ptl.y = pptlClient->y ;
        !            84: 
        !            85:      GpiLine (hps, &ptl) ;
        !            86: 
        !            87:           /*----------------------------------------
        !            88:              Middle Left to Pointer to Middle Right
        !            89:             ----------------------------------------*/
        !            90: 
        !            91:      ptl.x = 0 ;
        !            92:      ptl.y = pptlClient->y / 2 ;
        !            93: 
        !            94:      GpiMove (hps, &ptl) ;
        !            95:      GpiLine (hps, pptlPointerPos) ;
        !            96: 
        !            97:      ptl.x = pptlClient->x ;
        !            98: 
        !            99:      GpiLine (hps, &ptl) ;
        !           100:      }
        !           101: 
        !           102: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
        !           103:      {
        !           104:      static POINTL ptlClient, ptlPointerPos ;
        !           105:      HPS           hps ;
        !           106: 
        !           107:      switch (msg)
        !           108:           {
        !           109:           case WM_SIZE:
        !           110:                ptlClient.x = SHORT1FROMMP (mp2) ;
        !           111:                ptlClient.y = SHORT2FROMMP (mp2) ;
        !           112:                return 0 ;
        !           113:      
        !           114:           case WM_MOUSEMOVE:
        !           115:                hps = WinGetPS (hwnd) ;
        !           116: 
        !           117:                GpiSetMix (hps, FM_INVERT) ;
        !           118:                DrawWeb (hps, &ptlPointerPos, &ptlClient) ;
        !           119: 
        !           120:                ptlPointerPos.x = MOUSEMSG(&msg)->x ;
        !           121:                ptlPointerPos.y = MOUSEMSG(&msg)->y ;
        !           122: 
        !           123:                DrawWeb (hps, &ptlPointerPos, &ptlClient) ;
        !           124: 
        !           125:                WinReleasePS (hps) ;
        !           126:                return 1 ;
        !           127: 
        !           128:           case WM_PAINT:
        !           129:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
        !           130:                GpiErase (hps) ;
        !           131: 
        !           132:               GpiSetMix (hps, FM_INVERT) ;
        !           133:                DrawWeb (hps, &ptlPointerPos, &ptlClient) ;
        !           134: 
        !           135:                WinEndPaint (hps) ;
        !           136:                return 0 ;
        !           137:           }
        !           138:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !           139:      }

unix.superglobalmegacorp.com

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