home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sompar.zip / INFODLG.CPP next >
C/C++ Source or Header  |  1994-01-07  |  4KB  |  122 lines

  1. //
  2. // Project: Digitalk Parts like Toolbar and SOMObjects Demo
  3. // File:    Infodlg.hpp
  4. // Author:  Stewart Hyde
  5. // Created: Jan    7, 1994
  6. // Updated: Jan    7, 1994
  7. //
  8. // Description:
  9. //
  10.  
  11. #include <ireslib.hpp>
  12. #include <istring.hpp>
  13. #include <os2.h>
  14. #include "infodlg.hpp"
  15.  
  16. // ------------------------------------------------------------------------
  17. //  Class:                InfoDialog        
  18. //  Function:            InfoDialog    (constructor)
  19. //                
  20. //  Description:        This is the contructor for Information Dialog
  21. //       
  22. //  Input:                unsigned long DialogId - resource ID for dialog
  23. //                            IWindow *parentWin - parent window
  24. //                            IWindow *ownerWin  - owner window
  25. //
  26. //  Output:                N/A
  27. //
  28. //  Notes:
  29. //
  30. // ------------------------------------------------------------------------
  31.  
  32. InfoDialog::InfoDialog(unsigned long DialogId, IWindow * parentWnd, IWindow * ownerWnd)
  33.     : IFrameWindow(DialogId,parentWnd,ownerWnd)
  34. {
  35.     // ---------------------------------------------------------------------
  36.     //  Set default return value to false
  37.     // ---------------------------------------------------------------------
  38.  
  39.     DialogReturn=false;
  40.  
  41.     // ---------------------------------------------------------------------
  42.     //  setup command handler
  43.     // ---------------------------------------------------------------------
  44.  
  45.     handleEventsFor(this);
  46. }
  47.  
  48.  
  49. // ------------------------------------------------------------------------
  50. //  Class:                InfoDialog        
  51. //  Function:            DisplayDialog
  52. //                
  53. //  Description:        Display a Modal Information dialog
  54. //       
  55. //  Input:                N/A
  56. //
  57. //  Output:                Boolean - flag if command is process or not
  58. //
  59. //  Notes:
  60. //
  61. // ------------------------------------------------------------------------
  62.  
  63. Boolean InfoDialog::DisplayDialog()
  64. {
  65.     // ---------------------------------------------------------------------
  66.     //  Set focus and display the dialog (modal)
  67.     // ---------------------------------------------------------------------
  68.  
  69.     setFocus();
  70.     showModally();
  71.  
  72.     // ---------------------------------------------------------------------
  73.     //  return the result from command handler
  74.     // ---------------------------------------------------------------------
  75.  
  76.     return(DialogReturn);
  77. }
  78.  
  79. // ------------------------------------------------------------------------
  80. //  Class:                InfoDialog        
  81. //  Function:            comand
  82. //                
  83. //  Description:        dialog command event handler
  84. //       
  85. //  Input:                ICommandEvent &evt
  86. //
  87. //  Output:                Boolean
  88. //
  89. //  Notes:
  90. //                            Handles only OK and CANCEL
  91. //
  92. // ------------------------------------------------------------------------
  93.  
  94. Boolean InfoDialog :: command(ICommandEvent & cmdEvent)                         
  95. {                                                                          
  96.       switch (cmdEvent.commandId()) {       
  97.  
  98.         // ------------------------------------------------------------------
  99.         // OK Button - dialog return value is true and dismiss the dialog
  100.         // ------------------------------------------------------------------
  101.  
  102.         case DID_OK:   
  103.            DialogReturn=true;
  104.            dismiss(DID_OK);                                    
  105.            break;                               
  106.  
  107.         // ------------------------------------------------------------------
  108.         // CANCEL Button - dialog return value is true and dismiss the dialog
  109.         // ------------------------------------------------------------------
  110.  
  111.         case DID_CANCEL:    
  112.            DialogReturn=false;
  113.            dismiss(DID_CANCEL);                                    
  114.            break;                                
  115.     
  116.        default:
  117.              return(false);               //Return command not processed        
  118.   } 
  119.  
  120.   return(true);                       
  121. }                                                   // end InfoDialog :: command(...) 
  122.