|
|
1.1 ! root 1: /*-------------------------------------- ! 2: WEB.C -- Mouse Movement Demo Program ! 3: --------------------------------------*/ ! 4: ! 5: #define INCL_WIN ! 6: #define INCL_GPI ! 7: #include <os2.h> ! 8: ! 9: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ; ! 10: ! 11: int main (void) ! 12: { ! 13: static CHAR szClientClass [] = "Web" ; ! 14: static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | ! 15: FCF_SIZEBORDER | FCF_MINMAX | ! 16: FCF_SHELLPOSITION | FCF_TASKLIST ; ! 17: HAB hab ; ! 18: HMQ hmq ; ! 19: HWND hwndFrame, hwndClient ; ! 20: QMSG qmsg ; ! 21: ! 22: hab = WinInitialize (0) ; ! 23: hmq = WinCreateMsgQueue (hab, 0) ; ! 24: ! 25: WinRegisterClass (hab, szClientClass, ClientWndProc, ! 26: CS_SIZEREDRAW | CS_SYNCPAINT, 0) ; ! 27: ! 28: hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE, ! 29: &flFrameFlags, szClientClass, NULL, ! 30: 0L, NULL, 0, &hwndClient) ; ! 31: ! 32: WinSendMsg (hwndFrame, WM_SETICON, ! 33: WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE), ! 34: NULL) ; ! 35: ! 36: while (WinGetMsg (hab, &qmsg, NULL, 0, 0)) ! 37: WinDispatchMsg (hab, &qmsg) ; ! 38: ! 39: WinDestroyWindow (hwndFrame) ; ! 40: WinDestroyMsgQueue (hmq) ; ! 41: WinTerminate (hab) ; ! 42: return 0 ; ! 43: } ! 44: ! 45: VOID DrawWeb (HPS hps, POINTL *pptlPointerPos, POINTL *pptlClient) ! 46: { ! 47: POINTL ptl ; ! 48: // Lower Left --> Pointer --> Upper Right ! 49: ptl.x = 0 ; ! 50: ptl.y = 0 ; ! 51: GpiMove (hps, &ptl) ; ! 52: GpiLine (hps, pptlPointerPos) ; ! 53: GpiLine (hps, pptlClient) ; ! 54: // Upper Left --> Pointer --> Lower Right ! 55: ptl.x = 0 ; ! 56: ptl.y = pptlClient->y ; ! 57: GpiMove (hps, &ptl) ; ! 58: GpiLine (hps, pptlPointerPos) ; ! 59: ! 60: ptl.x = pptlClient->x ; ! 61: ptl.y = 0 ; ! 62: GpiLine (hps, &ptl) ; ! 63: // Lower Center --> Pointer --> Upper Center ! 64: ptl.x = pptlClient->x / 2 ; ! 65: ptl.y = 0 ; ! 66: GpiMove (hps, &ptl) ; ! 67: GpiLine (hps, pptlPointerPos) ; ! 68: ! 69: ptl.y = pptlClient->y ; ! 70: GpiLine (hps, &ptl) ; ! 71: // Left Center --> Pointer --> Right Center ! 72: ptl.x = 0 ; ! 73: ptl.y = pptlClient->y / 2 ; ! 74: GpiMove (hps, &ptl) ; ! 75: GpiLine (hps, pptlPointerPos) ; ! 76: ! 77: ptl.x = pptlClient->x ; ! 78: GpiLine (hps, &ptl) ; ! 79: } ! 80: ! 81: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) ! 82: { ! 83: static POINTL ptlClient, ptlPointerPos ; ! 84: HPS hps ; ! 85: ! 86: switch (msg) ! 87: { ! 88: case WM_SIZE: ! 89: ptlClient.x = SHORT1FROMMP (mp2) ; ! 90: ptlClient.y = SHORT2FROMMP (mp2) ; ! 91: return 0 ; ! 92: ! 93: case WM_MOUSEMOVE: ! 94: hps = WinGetPS (hwnd) ; ! 95: GpiSetMix (hps, FM_INVERT) ; ! 96: ! 97: DrawWeb (hps, &ptlPointerPos, &ptlClient) ; ! 98: ! 99: ptlPointerPos.x = MOUSEMSG(&msg)->x ; ! 100: ptlPointerPos.y = MOUSEMSG(&msg)->y ; ! 101: ! 102: DrawWeb (hps, &ptlPointerPos, &ptlClient) ; ! 103: ! 104: WinReleasePS (hps) ; ! 105: break ; // do default processing ! 106: ! 107: case WM_PAINT: ! 108: hps = WinBeginPaint (hwnd, NULL, NULL) ; ! 109: GpiErase (hps) ; ! 110: GpiSetMix (hps, FM_INVERT) ; ! 111: ! 112: DrawWeb (hps, &ptlPointerPos, &ptlClient) ; ! 113: ! 114: WinEndPaint (hps) ; ! 115: return 0 ; ! 116: } ! 117: return WinDefWindowProc (hwnd, msg, mp1, mp2) ; ! 118: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.