home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / genhdrs / cmdhdrs / cmdhdr2.hpp < prev    next >
Text File  |  1996-10-29  |  2KB  |  51 lines

  1. #ifndef _CMDHDR2_
  2. #define _CMDHDR2_
  3. //*********************************************************
  4. // Reusable Handlers - Simple Command Handler
  5. //
  6. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  7. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  8. // All Rights Reserved.
  9. //*********************************************************
  10. #include <ibase.hpp>         // For IC_PM/IC_WIN.
  11. #ifdef IC_PM
  12.   #define INCL_DOSPROCESS    // For DosBeep.
  13.   #define INCL_WINWINDOWMGR  // For CMDSRC_OTHER.
  14.   #include <os2.h>
  15.   #define BEEP(frequency,duration) (DosBeep(frequency,duration))
  16. #else
  17.   #include <windows.h>       // For Beep.
  18.   #define BEEP(frequency,duration) (Beep(frequency,duration))
  19. #endif
  20.  
  21. #include <icmdhdr.hpp>
  22. #include "cmdhdrs.h"
  23.  
  24. class TwoBeepCmdHandler : public ICommandHandler {
  25. protected:
  26. virtual Boolean
  27.   command ( ICommandEvent& event )
  28.   {
  29.     Boolean dontPassOn = false;
  30.     if ( event.commandId() == ID_TWO_BEEP_CMD )
  31.     {
  32.        // Issue the first beep; then send a command event to
  33.        // invoke another command handler to do the second beep.
  34.        BEEP( 200, 100 );
  35.        event.window()
  36.         ->sendEvent( IWindow::command,
  37. #ifdef IC_PM
  38.                      IEventParameter1( ID_ONE_BEEP_CMD ),
  39.                      IEventParameter2( CMDSRC_OTHER, false ) );
  40. #else
  41.                      IEventParameter1( ID_ONE_BEEP_CMD, 3 ),
  42.                      IEventParameter2( 0 ) );
  43. #endif
  44.        dontPassOn = true;
  45.     }
  46.     return dontPassOn;
  47.   }
  48. }; // TwoBeepCmdHandler
  49.  
  50. #endif // _CMDHDR2_
  51.