home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / notebook / vportdlg / deferacc.hpp next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  1.3 KB  |  37 lines

  1. //************************************************************
  2. // Notebook Control - Adding Notebook Windows to a Viewport
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //************************************************************
  8. #include <ihandler.hpp>
  9. #include <iwindow.hpp>
  10.  
  11. // Prevent Alt+F4 from closing the dialog.
  12. class DeferAccelerators : public IHandler {
  13. protected:
  14. virtual Boolean
  15.   dispatchHandlerEvent ( IEvent& event )
  16.   {
  17.     Boolean dontPassOn = false;
  18.     // Don't let the dialog/frame window process
  19.     // accelerator keys.  These should instead be passed
  20.     // up to the notebook's frame window for processing.
  21.     // The notebook does this for frame page windows.
  22.     // This handler lets us do it for frames that are
  23.     // children of page windows.
  24.     if (event.eventId() == 0x004B)  // WM_TRANSLATEACCEL.
  25.     {         // Emulate notebook's handling for page windows.
  26.        IWindow* parent = event.window()->parent();
  27.        if (parent)
  28.        {                // Forward event to parent (view port).
  29.           IEventResult result = parent->sendEvent( event );
  30.           event.setResult( result );
  31.        }
  32.        dontPassOn = true;  // Don't let the frame get it.
  33.     }
  34.     return dontPassOn;
  35.   }
  36. };
  37.