home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ab2c.zip / ivbab2c.hpp next >
Text File  |  1996-03-15  |  4KB  |  115 lines

  1. #ifndef _IVBAB2C_
  2.   #define _IVBAB2C_
  3.  
  4. /*******************************************************************************
  5. * FILE NAME: ivbvab2c.hpp                                                      *
  6. *                                                                              *
  7. * DESCRIPTION:                                                                 *
  8. *   Declaration of the class(es):                                              *
  9. *    IVBAboutToCloseHandler         - Handles SC_CLOSE                         *
  10. *    IVBCloseMessageHandler         - Handles WM_CLOSE                         *
  11. *                                                                              *
  12. * COPYRIGHT:                                                                   *
  13. *   IBM(R) VisualAge(TM) C++ for OS/2(R), Version 3                            *
  14. *   (C) Copyright IBM Corporation 1991, 1995.                                  *
  15. *    - Licensed Material - Program-Property of IBM - All Rights Reserved.      *
  16. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  17. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  18. *                                                                              *
  19. *   This program will not run in DOS mode.                                     *
  20. *                                                                              *
  21. *******************************************************************************/
  22.  
  23. #ifndef _IHANDLER_
  24.    #include <ihandler.hpp>
  25. #endif
  26.  
  27. #ifndef _ICMDHDR_
  28.   #include <icmdhdr.hpp>
  29. #endif
  30.  
  31. #ifndef _IMSGBOX_
  32.   #include <imsgbox.hpp>
  33. #endif
  34.  
  35. #define INCL_WINFRAMEMGR
  36. #include <os2.h>
  37.  
  38. /*----------------------------------------------------------------------------*/
  39. /* Align classes on four byte boundary.                                       */
  40. /*----------------------------------------------------------------------------*/
  41. #pragma pack(4)
  42.  
  43. //**************************************************************************
  44. // Class:   IVBAboutToCloseHandler                                         *
  45. //                                                                         *
  46. // Purpose: Handles the SC_CLOSE event.                                    *
  47. //                                                                         *
  48. //**************************************************************************
  49.  
  50. class IVBAboutToCloseHandler : public ICommandHandler {
  51. public:
  52.   IVBAboutToCloseHandler () {};
  53. protected:
  54. virtual Boolean
  55.  
  56.   systemCommand ( ICommandEvent& event )
  57.   {
  58.     if (event.commandId() == SC_CLOSE) {
  59.       IMessageBox msgbox (event.controlWindow());
  60.  
  61.       IMessageBox::Response result = msgbox.show ("Do you want to close?",
  62.           (IMessageBox::okCancelButton |
  63.            IMessageBox::defButton1 |
  64.            IMessageBox::applicationModal)
  65.         );
  66.       if (result == IMessageBox::ok) {
  67.         return false;
  68.       }
  69.       return true;
  70.     }
  71.     return false;
  72.   }
  73. };
  74.  
  75. //**************************************************************************
  76. // Class:   IVBCloseMessageHandler                                         *
  77. //                                                                         *
  78. // Purpose: Handles the WM_CLOSE event.                                    *
  79. //                                                                         *
  80. //**************************************************************************
  81.  
  82. class IVBCloseMessageHandler : public IHandler
  83. {
  84. typedef IHandler
  85.    Inherited;
  86. public:
  87.   IVBCloseMessageHandler() {};
  88. virtual ~IVBCloseMessageHandler() {};
  89. protected:
  90.   Boolean dispatchHandlerEvent( IEvent& event )
  91.   {
  92.     if (event.eventId() == WM_CLOSE) {
  93.       IMessageBox msgbox (event.controlWindow());
  94.  
  95.       IMessageBox::Response result = msgbox.show ("Do you want to close?",
  96.           (IMessageBox::okCancelButton |
  97.            IMessageBox::defButton1 |
  98.            IMessageBox::applicationModal)
  99.         );
  100.       if (result == IMessageBox::ok) {
  101.         return false;
  102.       }
  103.       return true;
  104.     }
  105.     return false;
  106.   }
  107. };
  108.  
  109. /*----------------------------------------------------------------------------*/
  110. /* Resume compiler default packing.                                           */
  111. /*----------------------------------------------------------------------------*/
  112. #pragma pack()
  113.  
  114. #endif
  115.