home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / help / helpothr / childhlp.cpp next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  2.7 KB  |  101 lines

  1. //*********************************************************
  2. // Using Help - Help for Special Cases
  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 <ibase.hpp>    // For IC_WIN or IC_PM.
  9. #ifdef IC_PM            // ChildHelpHandler is OS/2-only.
  10.  
  11. #define INCL_WINMESSAGEMGR  // For WM_HELP.
  12. #include <os2.h>
  13.  
  14. #include <iexcept.hpp>
  15. #include <ihelp.hpp>
  16. #include <iframe.hpp>
  17. #include <icconst.h>
  18. #include "childhlp.hpp"
  19.  
  20. #if IC_MAJOR_VERSION <= 310
  21.   #define IBaseErrorInfo IErrorInfo
  22. #endif
  23.  
  24. IBase::Boolean
  25.   ChildHelpHandler::dispatchHandlerEvent ( IEvent& event )
  26. {
  27.   unsigned long
  28.     activeWindow = true;
  29.   switch ( event.eventId() )
  30.   {
  31.      case WM_ACTIVATE:
  32.         // The frame window is gaining or losing activation.
  33.         activeWindow = event.parameter1().number1();
  34.         // Fall into the WM_HELP case.
  35.      case WM_HELP:
  36.         // Add this In case help is initialized or this handler
  37.         // is attached after the frame window is activated.
  38.         this->setActiveWindow( event, activeWindow );
  39.         break;
  40.      default:
  41.         break;
  42.   }
  43.   return false;
  44. }
  45.  
  46. ChildHelpHandler&
  47.   ChildHelpHandler::setActiveWindow ( IEvent& event,
  48.                                       Boolean active )
  49. {
  50.   IHelpWindow
  51.    *help = IHelpWindow::helpWindow( event.window() );
  52.   if ( help )
  53.   {
  54.      IFrameWindow
  55.       *frame = 0;
  56.      if ( active )
  57.      {
  58.         frame = (IFrameWindow*)event.window();
  59.      }                  // Use parent window instead? $HT!
  60.      help->setActiveWindow( frame, frame );
  61.   }
  62.   return *this;
  63. }
  64.  
  65. ChildHelpHandler&
  66.   ChildHelpHandler::handleEventsFor ( IFrameWindow* child )
  67. {                  // Overloaded version for better type safety.
  68.   IASSERTPARM( child != 0 );
  69.   IHandler::handleEventsFor( child );
  70.   return *this;
  71. }
  72.  
  73. ChildHelpHandler&
  74.   ChildHelpHandler::stopHandlingEventsFor ( IFrameWindow* child )
  75. {                  // Overloaded version for better type safety.
  76.   IASSERTPARM( child != 0 );
  77.   IHandler::stopHandlingEventsFor( child );
  78.   return *this;
  79. }
  80.  
  81. IHandler&
  82.   ChildHelpHandler::handleEventsFor ( IWindow*  )
  83. {           // Private to hide version in IHandler.
  84.   ITHROWLIBRARYERROR( IC_MEMBER_ACCESS_ERROR,
  85.                       IBaseErrorInfo::invalidRequest,
  86.                       IException::recoverable );
  87.   return *this;
  88. }
  89.  
  90. IHandler&
  91.   ChildHelpHandler::stopHandlingEventsFor ( IWindow* )
  92. {
  93.   // Private to hide version in IHandler.
  94.   ITHROWLIBRARYERROR( IC_MEMBER_ACCESS_ERROR,
  95.                       IBaseErrorInfo::invalidRequest,
  96.                       IException::recoverable );
  97.   return *this;
  98. }
  99.  
  100. #endif
  101.