Annotation of pmsdk/samples/petzold/chap10/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: #include <os2.h>
                      7: 
                      8: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
                      9: 
                     10: BOOL fFlipFlop ;
                     11: 
                     12: int main (void)
                     13:      {
                     14:      static char  szClientClass [] = "Beeper2" ;
                     15:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
                     16:                                  FCF_SIZEBORDER    | FCF_MINMAX  |
                     17:                                  FCF_SHELLPOSITION | FCF_TASKLIST ;
                     18:      HAB          hab ;
                     19:      HMQ          hmq ;
                     20:      HWND         hwndFrame, hwndClient ;
                     21:      QMSG         qmsg ;
                     22:      USHORT       idTimer ;
                     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, WS_VISIBLE,
                     30:                                      &flFrameFlags, szClientClass, NULL,
                     31:                                     0L, NULL, 0, &hwndClient) ;
                     32: 
                     33:      idTimer = WinStartTimer (hab, NULL, 0, 1000) ;
                     34: 
                     35:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     36:           {
                     37:           if (qmsg.msg == WM_TIMER && SHORT1FROMMP (qmsg.mp1) == idTimer)
                     38:                {
                     39:                WinAlarm (HWND_DESKTOP, WA_NOTE) ;
                     40:                fFlipFlop = !fFlipFlop ;
                     41:                WinInvalidateRect (hwndClient, NULL, FALSE) ;
                     42:                }
                     43:           else
                     44:                WinDispatchMsg (hab, &qmsg) ;
                     45:           }
                     46: 
                     47:      WinStopTimer (hab, NULL, idTimer) ;
                     48: 
                     49:      WinDestroyWindow (hwndFrame) ;
                     50:      WinDestroyMsgQueue (hmq) ;
                     51:      WinTerminate (hab) ;
                     52:      return 0 ;
                     53:      }
                     54: 
                     55: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     56:      {
                     57:      HPS   hps ;
                     58:      RECTL rcl ;
                     59: 
                     60:      switch (msg)
                     61:           {
                     62:           case WM_PAINT:
                     63:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     64: 
                     65:                WinQueryWindowRect (hwnd, &rcl) ;
                     66:                WinFillRect (hps, &rcl, fFlipFlop ? CLR_BLUE : CLR_RED) ;
                     67: 
                     68:                WinEndPaint (hps) ;
                     69:                return 0 ;
                     70:           }
                     71:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     72:      }

unix.superglobalmegacorp.com

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