home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nmoveh10.zip / NoMoveHandler.hpp < prev    next >
C/C++ Source or Header  |  1998-11-24  |  2KB  |  74 lines

  1. #ifndef NoMoveHandler_HPP
  2. #define NoMoveHandler_HPP
  3.  
  4. #define INCL_WINFRAMEMGR
  5. #include <os2.h>           // OS/2
  6. #include <ihandler.hpp>    // IHandler
  7.  
  8. /* class NoMoveHandler
  9.  *
  10.  * written by Stéphane Charette
  11.  * v1.0  23 November 1998 - initial version
  12.  *
  13.  * PURPOSE:       handle the necessary events to ensure that a window cannot
  14.  *                be moved (cancels out WM_QUERYTRACKINFO and WM_TRACKFRAME)
  15.  *
  16.  * REQUIREMENTS:  IBM VisualAge C++ version 3.0+ for OS/2 Warp version 4.0+
  17.  *                (may also work with Warp 3 -- untested)
  18.  *
  19.  * USAGE:         (see the file NoMoveHandler.cpp)
  20.  *                ...
  21.  *                IFrameWindow frame;
  22.  *                NoMoveHandler handler;
  23.  *                handler.handleEventsFor( &frame );
  24.  *                ...
  25.  *                handler.stopHandlingEventsFor( &frame );
  26.  *                ...
  27.  *
  28.  */
  29. class NoMoveHandler : public IHandler
  30. {
  31.    public:
  32.  
  33.       // start handling events for the specified window
  34.       virtual IHandler &handleEventsFor( IWindow *window )
  35.       {
  36.          // start the OCL event handling
  37.          IHandler::handleEventsFor( window );
  38.  
  39.          return *this;
  40.       }
  41.  
  42.       // stop handling events for the specified window
  43.       virtual IHandler &stopHandlingEventsFor( IWindow *window )
  44.       {
  45.          // stop the OCL event handling
  46.          IHandler::stopHandlingEventsFor( window );
  47.  
  48.          return *this;
  49.       }
  50.  
  51.    protected:
  52.  
  53.       // handle event processing
  54.       virtual Boolean dispatchHandlerEvent( IEvent &event )
  55.       {
  56.          // assume the event wont be handled
  57.          Boolean result = false;
  58.  
  59.          // look for the WM_VRNENABLED message
  60.          if(  (event.eventId() == WM_QUERYTRACKINFO) ||
  61.               (event.eventId() == WM_TRACKFRAME))
  62.          {
  63.             // prevent this message from being passed to the next handler
  64.             result = true;
  65.          }
  66.  
  67.          event.setResult(result);
  68.          return result;
  69.       }
  70. };
  71.  
  72. #endif
  73.  
  74.