Annotation of pmsdk/samples/petzold/chap07/beeper2.c, revision 1.1.1.1

1.1       root        1: /*--------------------------------------- 
                      2:    BEEPER2.C -- Timer Demo Program No. 2
                      3:   ---------------------------------------*/
                      4: 
                      5: #define INCL_WIN
                      6: 
                      7: #include <os2.h>
                      8: #include <stddef.h>
                      9: 
                     10: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
                     11: 
                     12: BOOL fFlipFlop ;
                     13: 
                     14: int main (void)
                     15:      {
                     16:      static char szClientClass [] = "Beeper2" ;
                     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:      USHORT     idTimer ;
                     24: 
                     25:      hab = WinInitialize (0) ;
                     26:      hmq = WinCreateMsgQueue (hab, 0) ;
                     27: 
                     28:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
                     29: 
                     30:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle,
                     31:                                      &flFrameFlags, szClientClass,
                     32:                                      "Timer Demo No. 2",
                     33:                                     0L, NULL, 0, &hwndClient) ;
                     34: 
                     35:      idTimer = WinStartTimer (hab, NULL, 0, 1000) ;
                     36: 
                     37:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     38:           {
                     39:           if (qmsg.msg == WM_TIMER && LOUSHORT (qmsg.mp1) == idTimer)
                     40:                {
                     41:                WinAlarm (HWND_DESKTOP, WA_NOTE) ;
                     42:                fFlipFlop = !fFlipFlop ;
                     43:                WinInvalidateRect (hwndClient, NULL, FALSE) ;
                     44:                }
                     45:           else
                     46:                WinDispatchMsg (hab, &qmsg) ;
                     47:           }
                     48: 
                     49:      WinStopTimer (hab, NULL, idTimer) ;
                     50: 
                     51:      WinDestroyWindow (hwndFrame) ;
                     52:      WinDestroyMsgQueue (hmq) ;
                     53:      WinTerminate (hab) ;
                     54:      return 0 ;
                     55:      }
                     56: 
                     57: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     58:      {
                     59:      HPS   hps ;
                     60:      RECTL rcl ;
                     61: 
                     62:      switch (msg)
                     63:           {
                     64:           case WM_PAINT:
                     65:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     66: 
                     67:                WinQueryWindowRect (hwnd, &rcl) ;
                     68:                WinFillRect (hps, &rcl, fFlipFlop ? CLR_BLUE : CLR_RED) ;
                     69: 
                     70:                WinEndPaint (hps) ;
                     71:                return 0 ;
                     72:           }
                     73:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     74:      }

unix.superglobalmegacorp.com

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