|
|
1.1 ! root 1: /*--------------------------------------- ! 2: BEEPER1.C -- Timer Demo Program No. 1 ! 3: ---------------------------------------*/ ! 4: ! 5: #define INCL_WIN ! 6: ! 7: #include <os2.h> ! 8: #include <stddef.h> ! 9: ! 10: #define ID_TIMER 1 ! 11: ! 12: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ; ! 13: ! 14: int main (void) ! 15: { ! 16: static char szClientClass [] = "Beeper1" ; ! 17: HAB hab ; ! 18: HMQ hmq ; ! 19: HWND hwndClient, hwndFrame ; ! 20: QMSG qmsg ; ! 21: ULONG flFrameFlags = FCF_STANDARD & ~FCF_MENU ; ! 22: ULONG flFrameStyle = WS_VISIBLE ; ! 23: ! 24: hab = WinInitialize (0) ; ! 25: hmq = WinCreateMsgQueue (hab, 0) ; ! 26: ! 27: WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ; ! 28: ! 29: hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle, ! 30: &flFrameFlags, szClientClass, ! 31: "Timer Demo No. 1", ! 32: 0L, NULL, 0, &hwndClient) ; ! 33: ! 34: WinStartTimer (hab, hwndClient, ID_TIMER, 1000) ; ! 35: ! 36: while (WinGetMsg (hab, &qmsg, NULL, 0, 0)) ! 37: WinDispatchMsg (hab, &qmsg) ; ! 38: ! 39: WinStopTimer (hab, hwndClient, ID_TIMER) ; ! 40: ! 41: WinDestroyWindow (hwndFrame) ; ! 42: WinDestroyMsgQueue (hmq) ; ! 43: WinTerminate (hab) ; ! 44: return 0 ; ! 45: } ! 46: ! 47: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) ! 48: { ! 49: static BOOL fFlipFlop ; ! 50: HPS hps ; ! 51: RECTL rcl ; ! 52: ! 53: switch (msg) ! 54: { ! 55: case WM_TIMER: ! 56: WinAlarm (HWND_DESKTOP, WA_NOTE) ; ! 57: fFlipFlop = !fFlipFlop ; ! 58: WinInvalidateRect (hwnd, NULL, FALSE) ; ! 59: return 0 ; ! 60: ! 61: case WM_PAINT: ! 62: hps = WinBeginPaint (hwnd, NULL, NULL) ; ! 63: ! 64: WinQueryWindowRect (hwnd, &rcl) ; ! 65: WinFillRect (hps, &rcl, fFlipFlop ? CLR_BLUE : CLR_RED) ; ! 66: ! 67: WinEndPaint (hps) ; ! 68: return 0 ; ! 69: } ! 70: return WinDefWindowProc (hwnd, msg, mp1, mp2) ; ! 71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.