Annotation of pmsdk/samples/petzold/chap10/beeper1.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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