home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / frame1 / minmax / minmaxh.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  2.3 KB  |  97 lines

  1. //*********************************************************
  2. // Frame Window Basics - Minimize/Maximize Handler Example
  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>
  9.  
  10. #ifdef IC_PM
  11.   #define INCL_WIN
  12.   #include <os2.h>
  13. #else
  14.   #include <windows.h>
  15. #endif
  16.  
  17. #include <iframe.hpp>
  18. #include <iswp.hpp>
  19.  
  20. #include "minmaxh.hpp"
  21.  
  22. MinMaxHandler
  23.  &MinMaxHandler::handleEventsFor ( IFrameWindow* frame )
  24. {
  25.   this->IHandler::handleEventsFor( frame );
  26.   return *this;
  27. }
  28.  
  29. IBase::Boolean
  30.   MinMaxHandler::dispatchHandlerEvent ( IEvent& event )
  31. {
  32.   Boolean
  33.     result = false;
  34.   switch ( event.eventId() )
  35.   {
  36. #ifdef IC_PM
  37.      case WM_ADJUSTFRAMEPOS:
  38.      {
  39.        ISWP
  40.         *swp = (ISWP*)(char*)( event.parameter1() );
  41.        if ( swp->flags() & SWP_MINIMIZE )
  42.           result = this->minimized( event );
  43.        else if ( swp->flags() & SWP_MAXIMIZE )
  44.           result = this->maximized( event );
  45.        else if ( swp->flags() & SWP_RESTORE )
  46.           result = this->restored( event );
  47.        break;
  48.      }
  49. #else
  50.      case WM_WINDOWPOSCHANGING:
  51.      {
  52.        PWINDOWPOS
  53.          windowPos( (PWINDOWPOS)(char*)
  54.                       event.parameter2().asUnsignedLong() );
  55.        if ( !( ( windowPos->flags & SWP_NOSIZE )  &&
  56.                ( windowPos->flags & SWP_NOMOVE ) ) )
  57.        {
  58.           unsigned long
  59.             style( GetWindowLong( event.dispatchingWindow()->handle(),
  60.                                   GWL_STYLE ) );
  61.           if ( style & WS_MINIMIZE )
  62.              result = this->minimized( event );
  63.           else if ( style & WS_MAXIMIZE )
  64.              result = this->maximized( event );
  65.           else
  66.              result = this->restored( event );
  67.        }
  68.        break;
  69.      }
  70. #endif
  71.      default:
  72.        break;
  73.   }
  74.   return result;
  75. }
  76.  
  77. IBase::Boolean MinMaxHandler::minimized ( IEvent& event )
  78. {
  79.   return false;
  80. }
  81.  
  82. IBase::Boolean MinMaxHandler::maximized ( IEvent& event )
  83. {
  84.   return false;
  85. }
  86.  
  87. IBase::Boolean MinMaxHandler::restored ( IEvent& event )
  88. {
  89.   return false;
  90. }
  91.  
  92. IHandler& MinMaxHandler::handleEventsFor ( IWindow* window )
  93. {
  94.   return this->IHandler::handleEventsFor( window );
  95. }
  96.  
  97.