home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / igpb1.zip / ADIALOG4.CPP next >
Text File  |  1994-03-01  |  5KB  |  82 lines

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 4: ATextDialog Class  (ADIALOG4.CPP)  */
  3. /*                                                                            */
  4. /* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
  5. /*                                                                            */
  6. /* DISCLAIMER OF WARRANTIES:                                                  */
  7. /*   The following [enclosed] code is sample code created by IBM              */
  8. /*   Corporation.  This sample code is not part of any standard IBM product   */
  9. /*   and is provided to you solely for the purpose of assisting you in the    */
  10. /*   development of your applications.  The code is provided "AS IS",         */
  11. /*   without warranty of any kind.  IBM shall not be liable for any damages   */
  12. /*   arising out of your use of the sample code, even if they have been       */
  13. /*   advised of the possibility of such damages.                              */
  14. /******************************************************************************/
  15.  
  16. //**************************************************************************
  17. // The entire file was created at version 4                                *
  18. //**************************************************************************
  19.  
  20. #include <ientryfd.hpp>                 //IEntryField Class
  21. #include <icmdevt.hpp>                  //ICommandEvent
  22. #include <istring.hpp>                  //IString Class
  23. #include <ireslib.hpp>                  //IResourceLibrary/IResourceId Class
  24.  
  25. #include "ahellow4.h"                   //Include our Symbolic definitions
  26. #include "adialog4.hpp"                 //ATextDialog Class
  27.  
  28. //**************************************************************************
  29. // ATextDialog :: ATextDialog - Constructor for text dialog window         *
  30. //**************************************************************************
  31. ATextDialog :: ATextDialog(IString & textString, IWindow * ownerWnd)
  32.              : IFrameWindow(4321, 0, ownerWnd, 
  33.                              IRectangle(IPoint(0,0), ISize(300,300)),
  34.                              IFrameWindow::defaultStyle(),
  35.                             "Dialog in Notebook"),
  36.                notebook(1234, this, this),
  37.                dlgFrame(IResourceId(WND_TEXTDIALOG), ¬ebook, ¬ebook),
  38.                textValue(textString)
  39. {
  40.   this->setClient(¬ebook);
  41.   INotebook::PageSettings Settings("Tab", "Status", 
  42.                                    INotebook::PageSettings::autoPageSize |
  43.                                    INotebook::PageSettings::majorTab);
  44.   notebook.addLastPage(Settings, &dlgFrame);
  45.   ICommandHandler::handleEventsFor(this);//Set self as command event handler
  46.  
  47.   textValue=textString ;                //Save textValue for exit of dialog
  48.   textField=new IEntryField(DID_ENTRY,  //Create entry field object using dialog
  49.     &dlgFrame);                              //  entry field
  50.   textField->setText(textString);       //Set top current "Hello, World" text
  51.   textField->setFocus();                //Set focus to entry field
  52.  
  53. } /* end ATextDialog :: ATextDialog(...) */
  54.  
  55. //**************************************************************************
  56. // ATextDialog :: ~ATextDialog - Destructor                                *
  57. //**************************************************************************
  58. ATextDialog :: ~ATextDialog()
  59. {
  60. } /* end ATextDialog :: ~TextDialog(...) */
  61.  
  62. //**************************************************************************
  63. // ATextDialog :: command - Process Commands                               *
  64. //**************************************************************************
  65. Boolean ATextDialog :: command(ICommandEvent& cmdevt)
  66. {
  67.   switch(cmdevt.commandId()) {
  68.     case DID_OK: // DID_OK              //Process OK Button
  69.       textValue = textField->text() ;   //Get Text from Dialog Entry Field
  70.       dismiss(DID_OK);             //Dismiss Dialog - Allow focus to main
  71.       return(true);                     //Return Processing Completed
  72.       break;
  73.  
  74.     case DID_CANCEL: // DID_CANCEL      //Process CANCEL Button
  75.       dismiss(DID_CANCEL);         //Dismiss Dialog - Allow focus to main
  76.       return(true);                     //Return Processing Completed
  77.       break;
  78.   }/* end switch */
  79.  
  80.   return(false);                       //Allow Default Processing to occur
  81. } /* end ATextDialog :: command(...) */
  82.