File:  [OS/2 SDKs] / pmsdk / samples / petzold / chap07 / beeper2.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:28:12 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: pmsdk-1988, HEAD
Microsoft OS/2 SDK PM 08-08-1988

/*--------------------------------------- 
   BEEPER2.C -- Timer Demo Program No. 2
  ---------------------------------------*/

#define INCL_WIN

#include <os2.h>
#include <stddef.h>

MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;

BOOL fFlipFlop ;

int main (void)
     {
     static char szClientClass [] = "Beeper2" ;
     HAB         hab ;
     HMQ         hmq ;
     HWND        hwndClient, hwndFrame ;
     QMSG        qmsg ;
     ULONG       flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
     ULONG       flFrameStyle = WS_VISIBLE ;
     USHORT	 idTimer ;

     hab = WinInitialize (0) ;
     hmq = WinCreateMsgQueue (hab, 0) ;

     WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;

     hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle,
                                     &flFrameFlags, szClientClass,
                                     "Timer Demo No. 2",
				     0L, NULL, 0, &hwndClient) ;

     idTimer = WinStartTimer (hab, NULL, 0, 1000) ;

     while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
          {
          if (qmsg.msg == WM_TIMER && LOUSHORT (qmsg.mp1) == idTimer)
               {
               WinAlarm (HWND_DESKTOP, WA_NOTE) ;
               fFlipFlop = !fFlipFlop ;
               WinInvalidateRect (hwndClient, NULL, FALSE) ;
               }
          else
               WinDispatchMsg (hab, &qmsg) ;
          }

     WinStopTimer (hab, NULL, idTimer) ;

     WinDestroyWindow (hwndFrame) ;
     WinDestroyMsgQueue (hmq) ;
     WinTerminate (hab) ;
     return 0 ;
     }

MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {
     HPS   hps ;
     RECTL rcl ;

     switch (msg)
          {
          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULL, NULL) ;

               WinQueryWindowRect (hwnd, &rcl) ;
               WinFillRect (hps, &rcl, fFlipFlop ? CLR_BLUE : CLR_RED) ;

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }

unix.superglobalmegacorp.com

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