home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ICLUI.ZIP / HELLO6 / ADIALOG6.CPP < prev    next >
Text File  |  1993-03-09  |  4KB  |  72 lines

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 6: ATextDialog Class  (ADIALOG6.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 "ahellow6.h"                   //Include our Symbolic definitions
  26. #include "adialog6.hpp"                 //ATextDialog Class
  27.  
  28. //**************************************************************************
  29. // ATextDialog :: ATextDialog - Constructor for text dialog window         *
  30. //**************************************************************************
  31. ATextDialog :: ATextDialog(IString & textString, IWindow * ownerWnd)
  32.              : IFrameWindow(IResourceId(WND_TEXTDIALOG), ownerWnd),
  33.                  textValue(textString)
  34. {
  35.   ICommandHandler::handleEventsFor(this);//Set self as command event handler
  36.  
  37.   textValue=textString ;                //Save textValue for exit of dialog
  38.   textField=new IEntryField(DID_ENTRY,  //Create entry field object using dialog
  39.     this);                              //  entry field
  40.   textField->setText(textString);       //Set top current "Hello, World" text
  41.   textField->setFocus();                //Set focus to entry field
  42.  
  43. } /* end ATextDialog :: ATextDialog(...) */
  44.  
  45. //**************************************************************************
  46. // ATextDialog :: ~ATextDialog - Destructor                                *
  47. //**************************************************************************
  48. ATextDialog :: ~ATextDialog()
  49. {
  50. } /* end ATextDialog :: ~TextDialog(...) */
  51.  
  52. //**************************************************************************
  53. // ATextDialog :: command - Process Commands                               *
  54. //**************************************************************************
  55. Boolean ATextDialog :: command(ICommandEvent& cmdevt)
  56. {
  57.   switch(cmdevt.commandId()) {
  58.     case DID_OK: // DID_OK              //Process OK Button
  59.       textValue = textField->text() ;   //Get Text from Dialog Entry Field
  60.       dismiss(DID_OK);             //Dismiss Dialog - Allow focus to main
  61.       return(true);                     //Return Processing Completed
  62.       break;
  63.  
  64.     case DID_CANCEL: // DID_CANCEL      //Process CANCEL Button
  65.       dismiss(DID_CANCEL);         //Dismiss Dialog - Allow focus to main
  66.       return(true);                     //Return Processing Completed
  67.       break;
  68.   }/* end switch */
  69.  
  70.   return(false);                       //Allow Default Processing to occur
  71. } /* end ATextDialog :: command(...) */
  72.