home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ICLUI.ZIP / HELLO6 / AHELLOW6.CPP < prev    next >
C/C++ Source or Header  |  1993-03-09  |  68KB  |  908 lines

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 6: Class Implementation (AHELLOW6.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. // NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE
  16. //**************************************************************************
  17. // C++ Hello World History and Key Functions:                              *
  18. //   Version 1:                                                            *
  19. //      - Creates and runs a simple application                            *
  20. //      - Creates the main window (IFrameWindow)                           *
  21. //      - Creates a static text control set to "Hello, World!" as the      *
  22. //         client window                                                   *
  23. //                                                                         *
  24. //   Version 2: (lines with v2 in column 79-80)                            *  v2
  25. //      - Create Main Window (AHellowWindow) as subclass of IFrameWindow   *   .
  26. //      - Gets the "Hello, World!!" text string and other items from a     *   .
  27. //         resource file                                                   *   .
  28. //      - Sets the window title from a resource file                       *   .
  29. //      - Creates and sets the information area at the bottom of the       *   .
  30. //         client area                                                     *  v2
  31. //                                                                         *
  32. //   Version 3: (lines with v3 in column 79-80)                            *  v3
  33. //      - Add Alignment (Left, Center, Right) Menu Bar                     *   .
  34. //      - Add Command Processing to set the "Hello, World" alignment       *   .
  35. //      - Place check in front of the Left, Center or Right Menu Item      *   .
  36. //      - Create and maintain Status Line with current alignment status    *  v3
  37. //                                                                         *
  38. //   Version 4: (lines with v4 in column 79-80)                            *  v4
  39. //      - Add Accelerator Keys for Left (F7), Center(F8), Right(F9)        *   .
  40. //      - Modify Left, Center and Right Menu Items to show function key    *   .
  41. //      - Modify Menu Bar to create Edit Menu and "text..." Menu Item      *   .
  42. //      - Add ADialogText to allow user to change "Hello, World" text      *   .
  43. //      - Add Push Buttons & Set Canvas to change alignment                *  v4
  44. //                                                                         *
  45. //   Version 5: (lines with v5 in column 79-80)                            *  v5
  46. //      - Code a new control (AEarthWindow) using PM Graphics calls        *   .
  47. //      - Add AEarthWindow to the bottom of the client area                *   .
  48. //      - Add Help Windows for the Main, Dialog, Entry Field Windows       *   .
  49. //      - Use Split Canvas as the Client Area                              *   .
  50. //      - Add ListBox to Client Area to change "Hello, World" text         *  v5
  51. //                                                                         *
  52. //   Version 6: (lines with v6 in column 79-80)                            *  v6
  53. //      - Command Line option to use Enlish or Portuguese DLL resources    *   .
  54. //      - Add Open Menu Item and use File Dialog                           *   .
  55. //      - Show MessageBox when can not read input file from File Dialog    *   .
  56. //      - Add Menu PopUp for changing the alignment                        *   .
  57. //      - Change Status Area to Split Canvas and add Date & Time           *   .
  58. //      - Add ATimeHandler & Update Time in Status Area                    *   .
  59. //      - Add HELLOWPS.CMD to create Workplace Folder with Programs        *  v6
  60. //**************************************************************************
  61.                                         //Include IBM UI class headers:
  62. #include <iapp.hpp>                     //IApplication Class
  63. #include <istattxt.hpp>                 //IStaticText Class
  64. #include <imenubar.hpp>                 //IMenuBar Class                      v3
  65. #include <istring.hpp>                  //IString Class                       v4
  66. #include <ihelp.hpp>                    //IHelpWindow Class                   v5
  67. #include <ihelphdr.hpp>                 //IHelpHandler Class                  v5
  68. #include <isplitcv.hpp>                 //ISplitCanvas Class                  v5
  69. #include <isetcv.hpp>                   //ISetCanvas Class                    v4
  70. #include <ipushbut.hpp>                 //IPushButton Class                   v4
  71. #include <iinfoa.hpp>                   //IInfoArea Class                     v2
  72. #include <imsgbox.hpp>                  //IMessageBox Class                   v6
  73. #include <ifiledlg.hpp>                 //IFileDialog                         v6
  74. #include <ifontdlg.hpp>                 //IFontDialog                         v6
  75. #include <imenuevt.hpp>                 //IMenuEvent                          v6
  76. #include <ipopmenu.hpp>                 //IPopUpMenu                          v6
  77. #include <icolor.hpp>                   //IColor                              v6
  78. #include <ilistbox.hpp>                 //IListBox                            v5
  79. #include <inotebk.hpp>                  //INoteBook                           v6
  80. #include <idate.hpp>                    //IDate                               v6
  81. #include <itime.hpp>                    //ITime                               v6
  82. #include <ifont.hpp>                    //IFont                               v3
  83. #include <iprofile.hpp>                 //IProfile                            v6
  84. #include <ithread.hpp>                  //IThread for Timer Call to PM        v6
  85. #define INCL_WINTIMER                   //Include OS/2 Timer Calls            v6
  86. #include <os2.h>                        //os/2.h to call beep if error        v6
  87. #include <iostream.h>                   //iostream                            v6
  88. #include <fstream.h>                    //fstream                             v6
  89. #include <stdlib.h>                     //stdlib                              v6
  90.  
  91. #include "ahellow6.hpp"                 //Include AHelloWindow Class headers  v2
  92. #include "ahellow6.h"                   //Include our Symbolic definitions    v2
  93. #include "adialog6.hpp"                 //ATextDialog Class                   v4
  94. #include "aearthw6.hpp"                 //AEarthWindow Class                  v5
  95. #include "acolorw6.hpp"                 //AColorWindow Class                  v6
  96. #include "aspeedw6.hpp"                 //ASpeedWindow Class                  v6
  97.  
  98. //*************************************************************************
  99. // main  - Application entry point                                        *
  100. //*************************************************************************
  101. int main(int argc, char **argv)         //Main Procedure with no parameters   v6
  102. {
  103.   IString dllName("AHELLOW");           //Get Base DLL Name                   v6
  104.   IString langKey("E");                 //Language Key                         .
  105.   IString langOption("");               //Language Option                      .
  106.   int i, imax;                          //Loop variables                      v6
  107.  
  108.   IApplication::current().              //Get current                         v6
  109.     setArgs(argc, argv);                //  and set command line parameters    .
  110.   IThread::current().initializePM();    // Initialize PM environment.          .
  111.   imax=IApplication::current().argc();  //Get number of command line parms     .
  112.   for (i=1; i < imax; ++i)              //Check input command parameters       .
  113.   {                                     //                                     .
  114.     langOption=IApplication::current()  //Get current application and          .
  115.       .argv(i).upperCase();             //  command line argument as upper case.
  116.     if (langOption.isAbbreviationFor(   //If Portuguese Option Then            .
  117.         "/PORTUGUESE", 2))              //                                     .
  118.       langKey = IString('P');           //  Set to load Portuguese DLL         .
  119.   } /* endfor */                        //                                     .
  120.   dllName+=langKey;                     //Add Language Letter to DLL Name      .
  121.   try                                   //Try to set the user resource DLL     .
  122.   {                                     //                                     .
  123.     IApplication::current().            //Get current application              .
  124.       setUserResourceLibrary(dllName);  //  Set the Name of Resoure DLL        .
  125.   }                                     //                                     .
  126.   catch (IException& exc)               //Catch Error trying to load DLL       .
  127.   {                                     //DLL probably not in libpath          .
  128.     DosBeep(750,1000) ;                 //Report Error via beep                .
  129.     IFrameWindow * msgWindow=new        //Create our main window on the desktop.
  130.       IFrameWindow(0x1000);             //  Pass in our Window ID              .
  131.  
  132.     IStaticText * msg=new IStaticText(  //Create static text control with      .
  133.       0x1010, msgWindow, msgWindow);    //  msgWindow as owner & parent        .
  134.     msg->setText(                       //Set the text in Static Text Control  .
  135.       "Can not load ResourcDLL");       //                                     .
  136.     msg->setAlignment(                  //Set Alignment to Center in both      .
  137.       IStaticText::centerCenter);       //  directions                         .
  138.  
  139.     msgWindow->sizeTo(ISize(400,300));  //Set the size of the window           .
  140.     msgWindow->setClient(msg);          //Set hello control as Client Window   .
  141.     msgWindow->setFocus();              //Set focus to msg window              .
  142.     msgWindow->show();                  //Set to show msg window               .
  143.  
  144.     IApplication::current().run();      //Get the current application and      .
  145.     exit(3) ;                           //Exit Program with error              .
  146.   }                                     //                                    v6
  147.   AHelloWindow mainWindow (WND_MAIN);   //Create our main window on the
  148.                                         // desktop
  149.   IApplication::current().run();        //Get the current application and
  150.                                         // run it
  151. } /* end main */
  152.  
  153. //**************************************************************************
  154. // AHelloWindow :: AHelloWindow - Constructor for our main window          *
  155. //**************************************************************************
  156. AHelloWindow :: AHelloWindow(unsigned long windowId)
  157.   : IFrameWindow (                      //Call IFrameWindow constructor       v2
  158.     IFrameWindow::defaultStyle()        //  Use default plus                  v2
  159.     | IFrameWindow::minimizedIcon       //  Get Minimized Icon from  RC file  v2
  160.     | IFrameWindow::accelerator         //  Get Accelerator Table from RC filev4
  161.     | IFrameWindow::animated,           //  Set to show with "animation"      v6
  162.     windowId)                           //  Main Window ID
  163. {
  164.   filename=NULL;                        //Set to fileName to NULL             v6
  165.   color=NULL;                           //Set color window to NULL             .
  166.   demo=false;                           //Demo is off                          .
  167.   demoIndex=0;                          //Set Demo Index to Zero               .
  168.   demoTicks=3;                          //Set Ticks per Demo Code             v6
  169.  
  170.   setupClient();                        //Setup Client Window                 v5
  171.   setupStatusArea();                    //Setup Status Area                    .
  172.   setupInfoArea();                      //Setup Information Area              v5
  173.   setupButtons();                       //Setup Buttons                       v4
  174.   setupMenuBar();                       //Setup Menu Bar                      v5
  175.   setupHelp();                          //Setup Help                          v5
  176. //  readProfile();                        //Read Profile                        v6
  177.  
  178.   sizeTo(ISize(500,400));               //Set the size of main window         v2
  179.   setFocus();                           //Set focus to main window
  180.   show();                               //Set to show main window
  181.   ATimeHandler::handleEventsFor(this);  //Set self as time handler            v6
  182.  
  183. } /* end AHelloWindow :: AHelloWindow(...) */
  184.  
  185. //**************************************************************************  v6
  186. // AHelloWindow :: AHelloWindow - Destructor for our main window           *   .
  187. //**************************************************************************   .
  188. AHelloWindow :: ~AHelloWindow()         //Destructor for AHelloWindow          .
  189. {                                       //                                     .
  190.   ATimeHandler::stopHandlingEventsFor(this);//Stop Timer                       .
  191. } /* end AHelloWindow :: ~AHelloWindow(...) */                              //v6
  192.  
  193. //**************************************************************************  v6
  194. // AHelloWindow :: speed()                                                 *   .
  195. //**************************************************************************   .
  196. int AHelloWindow :: speed()             //                                     .
  197. {                                       //                                     .
  198.   return demoTicks;                     //                                     .
  199. } /* end AHelloWindow :: speed() */                                         //v6
  200.  
  201. //**************************************************************************  v6
  202. // AHelloWindow :: setSpeed()                                              *   .
  203. //**************************************************************************   .
  204. Boolean AHelloWindow :: setSpeed(int value)             //Set Demo Speed                       .
  205. {                                       //                                     .
  206.   demoTicks=value;                      //Set the demo ticks                   .
  207.   demoCount=value;                      //Set the current demo counter         .
  208.   return true;                          //                                     .
  209. } /* end AHelloWindow :: setSpeed() */                                      //v6
  210.  
  211. //**************************************************************************  v4
  212. // AHelloWindow :: setupButtons                                            *   .
  213. //   Setup Buttons                                                         *   .
  214. //**************************************************************************   .
  215. Boolean AHelloWindow :: setupButtons()  //Setup Buttons                        .
  216. {                                       //                                     .
  217.   ISetCanvas    * buttons;              //Define canvas of buttons             .
  218.   IPushButton   * helpButton;           //Define Help Button                   .
  219.                                         //                                     .
  220.   buttons=new ISetCanvas(WND_BUTTONS,   //Create a Set Canvas for Buttons      .
  221.     this, this) ;                       //  Parent and Owner=me                .
  222.   buttons->setMargin(ISize());          //Set Canvas Margins to zero           .
  223.   buttons->setPad(ISize());             //Set Button Canvas Pad to zero        .
  224.   leftButton=new IPushButton(MI_LEFT,   //Create Left Push Button              .
  225.     buttons, buttons, IRectangle(),     //  Parent, Owner=Button Canvas        .
  226.     IPushButton::defaultStyle() |       //  Use Default Styles plus            .
  227.     IControl::tabStop);                 //  tabStop                            .
  228.   leftButton->setText(STR_LEFTB);       //Set Left Button Text                 .
  229.   centerButton=new IPushButton(MI_CENTER,//Create Left Push Button             .
  230.     buttons, buttons, IRectangle(),     //  Parent, Owner=Button Canvas        .
  231.     IPushButton::defaultStyle() |       //  Use Default Styles plus            .
  232.     IControl::tabStop);                 //  tabStop                            .
  233.   centerButton->setText(STR_CENTERB);   //Set Center Button Text               .
  234.   rightButton=new IPushButton(MI_RIGHT, //Create Right Push Button             .
  235.     buttons, buttons, IRectangle(),     //  Parent, Owner=Button Canvas        .
  236.     IPushButton::defaultStyle() |       //  Use Default Styles plus            .
  237.     IControl::tabStop);                 //  tabStop                            .
  238.   rightButton->setText(STR_RIGHTB);     //Set Right Button Text               v4
  239.   helpButton=new IPushButton(MI_HELP,   //Create Right Push Button            v5
  240.     buttons, buttons, IRectangle(),     //  Parent, Owner=Button Canvas        .
  241.     IPushButton::defaultStyle() |       //  Use Default Styles plus            .
  242.     IPushButton::help |                 //  Help Style                         .
  243.     IControl::tabStop);                 //  tabStop                            .
  244.   helpButton->setText(STR_HELPB);       //Set Help Button Text                v5
  245.   addExtension(buttons,                 //Add Buttons below client area       v4
  246.     IFrameWindow::belowClient,          //  below client and                   .
  247.     30UL);                              //  unsigned long height in pixels     .
  248.   return true;                          //Return                               .
  249. } /* end AHelloWindow :: setupButtons() */                                  //v4
  250.  
  251. //**************************************************************************  v5
  252. // AHelloWindow :: setupHelp()                                             *   .
  253. //   Setup Help                                                            *   .
  254. //**************************************************************************   .
  255. Boolean AHelloWindow :: setupHelp()     //Setup Help Area                      .
  256. {                                       //                                     .
  257.   help=new IHelpWindow(HELP_TABLE,      //Create Help Window Object            .
  258.     this);                              //Setup Help info                      .
  259.   help->addLibraries("AHELLOW6.HLP");   //  set self, help table filename      .
  260.   help->setTitle(STR_HTITLE);           //Set the Help Window Title            .
  261.                                         //                                     .
  262.   AHelpHandler* phelpHandler=           //Create Custon Help Handler to        .
  263.     new AHelpHandler();                 //  handle the Keys Help               .
  264.   phelpHandler->handleEventsFor(this);  //Start Help Handler                   .
  265.   return true;                          //                                     .
  266. } /* end AHelloWindow :: setupHelp() */                                     //v5
  267.  
  268. //**************************************************************************  v5
  269. // AHelloWindow :: setupClient()                                           *   .
  270. //   Setup Client                                                          *   .
  271. //**************************************************************************   .
  272. Boolean AHelloWindow :: setupClient()   //Setup Client Window                  .
  273. {                                       //                                     .
  274.   clientWindow=new ISplitCanvas(        //Create Canvas                        .
  275.     WND_CANVAS, this, this);            //  with Window Id, parent, owner      .
  276.   setClient(clientWindow);              //Set canvas as Client Window          .
  277.  
  278.   helloCanvas=new ISplitCanvas(         //Create Hello Canvas                  .
  279.     WND_HCANVAS, clientWindow,          //  with Window Id, parent             .
  280.     clientWindow);                      //  and owner                          .
  281.   helloCanvas->setOrientation(          //Set the orientation                  .
  282.     ISplitCanvas::horizontalSplit);     //  to horizontal                      .
  283.  
  284.   hello=new IStaticText(WND_HELLO,     //Create Static Text Control
  285.     helloCanvas, helloCanvas);          //  Pass in client as owner & parent  v6
  286.  
  287.   earthWindow=new AEarthWindow          //Create Earth Graphic Window         v5
  288.     (WND_EARTH, helloCanvas);           //  Set Window ID, client-owner/parentv6
  289.  
  290.   AMenuHandler * mh=new AMenuHandler(); //Create Menu Handler                 v6
  291.   mh->handleEventsFor(hello);           //Set Menu Handler for hello           .
  292.   ICommandHandler::handleEventsFor(hello);//Set self as command event handler v6
  293.  
  294.   hello->setText(STR_HELLO);            //Set text                            v2
  295.   IFont tempFont("Helv", 16);           //Create Temp. Font                   v6
  296.   hello->setFont(tempFont);             //Set Font for "Hello, World" Text    v6
  297.  
  298.   if (IApplication::current().argc()>1) //Check number of command line parms  v6
  299.   {                                     //                                     .
  300.     filename=                           //                                     .
  301.       IApplication::current().argv(1);  //Get filename for command line        .
  302.     ifstream infile(filename);          //Input file stream                    .
  303.     if (infile)                         //Does file exist?                     .
  304.     {                                   //  Yes, File does exist               .
  305.       cin=infile.rdbuf();               //  Set cin to infile                  .
  306.       hello->setText(IString().lineFrom(cin));//Set text in Static Text Control.
  307.       infile.close();                   //  Close input file                   .
  308.     }                                   //                                     .
  309.   } /* endif */                         //                                    v6
  310.   hello->setAlignment(                  //Set Alignment to Center in both
  311.     IStaticText::centerCenter);         //    directions
  312.  
  313.   listBox=new IListBox(WND_LISTBOX,     //Create ListBox                      v5
  314.     clientWindow, clientWindow,         //  Parent/Owner is ClientWindow       .
  315.     IRectangle(),                       //                                     .
  316.     IListBox::defaultStyle() |          //                                     .
  317.     IControl::tabStop |                 //  Set Tab Stop                       .
  318.     IListBox::noAdjustPosition);        //  Allow the Canvas to control size   .
  319.   listBox->addAsc("Hello, World!");     //Add "Hello, World!"                  .
  320.   listBox->addAsc("Hi, World!");        //Add "Hi, World!"                     .
  321.   listBox->addAsc("Howdy, World!");     //Add "Howdy, World!"                  .
  322.   listBox->addAsc("Alo, Mundo!");       //Add Portuguese Version               .
  323.   listBox->addAsc("Ola, Mondo!");       //Add Spain                            .
  324.   listBox->addAsc("Hallo wereld!");     //Add Dutch                            .
  325.   listBox->addAsc("Hallo Welt!");       //Add German                           .
  326.   listBox->addAsc("Bonjour le monde!"); //Add French                           .
  327.   ISelectHandler::handleEventsFor(listBox);//Set self as select event handler v5
  328.  
  329.   clientWindow->setSplitWindowPercentage(//Set the Window Percentage for      v5
  330.     helloCanvas, 60);                   //  the helloCanvas to 60              .
  331.   clientWindow->setSplitWindowPercentage(//Set the Window Percentage for       .
  332.     listBox, 40);                       //  the listBox to 40                 v5
  333.  
  334.   return true;                          //                                    v5
  335. } /* end AHelloWindow :: setupClient() */                                   //v5
  336.  
  337. //**************************************************************************  v5
  338. // AHelloWindow :: setupInfoArea()                                         *   .
  339. //   Setup Information Area                                                *   .
  340. //**************************************************************************   .
  341. Boolean AHelloWindow :: setupInfoArea() //Setup Information Area               .
  342. {                                       //                                    v5
  343.   infoArea=new IInfoArea(this);         //Create the information area         v2
  344.   infoArea->setInactiveText(STR_INFO);  //Set information area text from RC   v2
  345.   setExtensionSize(infoArea,            //                                    v5
  346.     (int)IFont(infoArea).maxCharHeight());//and specify height                 .
  347.   return true;                          //                                     .
  348. } /* end AHelloWindow :: setupInfoArea() */                                 //v5
  349.  
  350. //**************************************************************************  v5
  351. // AHelloWindow :: setupMenuBar()                                          *   .
  352. //   Setup Menu Bar                                                        *   .
  353. //**************************************************************************   .
  354. Boolean AHelloWindow :: setupMenuBar()  //Setup Menu Bar                       .
  355. {                                       //                                     .
  356.   ICommandHandler::handleEventsFor(this);//Set self as command event handler  v5
  357.   menuBar=new IMenuBar(WND_MAIN,        //Create Menu Bar for main window     v3
  358.     this);                              //  Set self as parent                 .
  359.   menuBar->checkItem(MI_CENTER);        //Place Check on Center Menu Item     v3
  360.   menuBar->disableItem(MI_DEMO_STOP);   //Disable Stop Menu Item              v6
  361.   return true;                          //                                    v5
  362. } /* end AHelloWindow :: setupMenuBar() */                                  //v5
  363.  
  364. //**************************************************************************  v5
  365. // AHelloWindow :: setupStatusArea()                                       *   .
  366. //   Setup Statue Area                                                     *   .
  367. //**************************************************************************   .
  368. Boolean AHelloWindow :: setupStatusArea()//Setup Status Area                  v5
  369. {                                       //                                    v6
  370.   statusCanvas=new ISplitCanvas         //Create Status Canvas with           v6
  371.     (WND_STATUSCANVAS, this, this);     //  Parent/Owner=me                   v6
  372.  
  373.   statusLine = new IStaticText          //Create Status Area using Static Textv3
  374.     (WND_STATUS, statusCanvas,          //  Window ID, owner, parent          v3
  375.      statusCanvas);                     //                                    v6
  376.   statusLine->setText(STR_CENTER);      //Set Status Text to "Center" from Resv3
  377.  
  378.   date = new IStaticText                //Create Date using Static Text       v6
  379.     (WND_TIME, statusCanvas,            //  Window ID, owner, parent           .
  380.      statusCanvas);                     //                                     .
  381.   date->setText(IDate().asString());    //Set Text to current date            v6
  382.  
  383.   time = new IStaticText                //Create Time using Static Text       v6
  384.     (WND_DATE, statusCanvas,            //  Window ID, owner, parent           .
  385.      statusCanvas);                     //                                     .
  386.   time->setText(ITime().asString());    //Set Text to current time            v6
  387.  
  388.   statusCanvas->setSplitWindowPercentage(//Set the Window Percentage for      v6
  389.     statusLine, 50);                    //  statusLine                         .
  390.   statusCanvas->setSplitWindowPercentage(//Set the Window Percentage for       .
  391.     date, 25);                          //  date                               .
  392.   statusCanvas->setSplitWindowPercentage(//Set the Window Percentage for       .
  393.     time, 25);                          //  time                              v6
  394.  
  395.   addExtension(statusCanvas,            //Add Status Canvas                   v6
  396.     IFrameWindow::aboveClient,          //  above the client window           v3
  397.     IFont(statusLine).maxCharHeight()); //  and specify height                v6
  398.   return true;                          //                                    v6
  399. } /* end AHelloWindow :: setupStatusArea() */                               //v6
  400.  
  401. //**************************************************************************  v5
  402. // AHelloWindow :: selected(...)                                           *   .
  403. //   Handle selected command from list box                                 *   .
  404. //                                                                         *   .
  405. // Note: It would be easy to change this selected member function to enter *   .
  406. //**************************************************************************   .
  407. Boolean AHelloWindow :: selected(IControlEvent & evt)                       // .
  408. {                                                                           // .
  409.   IListBox::Cursor lbCursor(*listBox);  //List Box Cursor                      .
  410.   lbCursor.setToFirst();                //Set to first item selected           .
  411.   setText(listBox->elementAt(lbCursor));//Set Hello Text to Selected Item      .
  412.   return true;                          //Return Command Processed             .
  413. } /* end AHelloWindow :: selected(...) */                                   //v5
  414.  
  415. //**************************************************************************  v3
  416. // AHelloWindow :: command                                                 *   .
  417. //   Handle menu commands                                                  *   .
  418. //**************************************************************************   .
  419. Boolean AHelloWindow :: command(ICommandEvent & cmdEvent)                   // .
  420. {                                                                           //v3
  421.   switch (cmdEvent.commandId()) {       //Get command id                      v3
  422.     case MI_CENTER:                     //Code to Process Center Command Item v3
  423.       return setCenterAlignment();      //  Set Center Alignment and Return   v6
  424.       break;                            //                                    v3
  425.  
  426.     case MI_LEFT:                       //Code to Process Left Command Item   v3
  427.       return setLeftAlignment();        //  Set Left Alignment and Return     v6
  428.       break;                            //                                    v3
  429.  
  430.     case MI_RIGHT:                      //Code to Process Right Command Item  v3
  431.       return setRightAlignment();       //  Set Right Alignment and Return    v6
  432.       break;                            //                                    v3
  433.  
  434.     case MI_TEXT:                       //Code to Process Text Command        v4
  435.       return openText();                //  Open Text Dialog and Return       v6
  436.       break;                            //                                    v4
  437.  
  438.     case MI_GENERAL_HELP:               //Code to Process Help for help       v5
  439.       help->show(IHelpWindow::general); //Show General Help Panel              .
  440.       return(true);                     //Return command processed             .
  441.       break;                            //                                    v5
  442.  
  443.     case MI_OPEN:                       //Code to Process Open                v6
  444.       return openFile();                //  Open File and Return               .
  445.       break;                            //                                    v6
  446.  
  447.     case MI_DEMO_START:                 //Code to Process Demo Start          v6
  448.       return startDemo();               //  Call and Return                    .
  449.       break;                            //                                    v6
  450.  
  451.     case MI_DEMO_STOP:                  //Code to Process Demo Stop           v6
  452.       return stopDemo();                //  Call and Return                    .
  453.       break;                            //                                    v6
  454.  
  455.     case MI_DEMO_SPEED:                 //Code to Process Demo Speed...       v6
  456.       return openSpeed();               //  Call and Return                    .
  457.       break;                            //                                    v6
  458.  
  459.     case MI_COLOR:                      //Code to Process Color Menu          v6
  460.       return openColor();               //  Call and Return                    .
  461.       break;                            //                                    v6
  462.  
  463.     case MI_FONT:                       //Code to Process Font Menu           v6
  464.       return openFont();                //  Call and Return                    .
  465.       break;                            //                                    v6
  466.  
  467.     case MI_READ_PROFILE:               //Code to Process Read Profile Menu IDv6
  468.       return readProfile();             //Read Profile                         .
  469.       break;                            //                                    v6
  470.  
  471.     case MI_UPDATE_PROFILE:             //File Update Profile Menu ID         v6
  472.       return updateProfile();           //  Call and Return                    .
  473.       break;                            //                                    v6
  474.  
  475.   } /* end switch */                    //                                    v3
  476.   return(false);                        //Return command not processed        v3
  477. } /* end AHelloWindow :: command(...) */                                    //v3
  478.  
  479. //**************************************************************************  v6
  480. // AHelloWindow :: setLeftAlignment()                                      *   .
  481. //   Set Left Alignment                                                    *   .
  482. //**************************************************************************   .
  483. Boolean AHelloWindow :: setLeftAlignment()//Set Left Alignment                 .
  484. {                                       //                                     .
  485.   hello->setAlignment(                  //Set alignment of hello text to      v3
  486.     IStaticText::centerLeft);           //  center-vertical, left-horizontal   .
  487.   statusLine->setText(STR_LEFT);        //Set Status Text to "Left" from Res   .
  488.   menuBar->uncheckItem(MI_CENTER);      //Uncheck Center Menu Item             .
  489.   menuBar->checkItem(MI_LEFT);          //Place Check on Left Menu Item        .
  490.   menuBar->uncheckItem(MI_RIGHT);       //Uncheck Right Menu Item             v3
  491.   return true;                          //Return                              v6
  492. } /* end AHelloWindow :: setLeftAlignmnet() */                              //v6
  493.  
  494. //**************************************************************************  v6
  495. // AHelloWindow :: setCenterAlignment()                                    *   .
  496. //   Set Center Alignment                                                  *   .
  497. //**************************************************************************   .
  498. Boolean AHelloWindow :: setCenterAlignment()//Set Center Alignment             .
  499. {                                       //                                     .
  500.   hello->setAlignment(                  //Set alignment of hello text to      v3
  501.     IStaticText::centerCenter);         //  center-vertical, center-horizontal .
  502.   statusLine->setText(STR_CENTER);      //Set Status Text to "Center" from Res .
  503.   menuBar->checkItem(MI_CENTER);        //Place Check on Center Menu Item      .
  504.   menuBar->uncheckItem(MI_LEFT);        //Uncheck Left Menu Item               .
  505.   menuBar->uncheckItem(MI_RIGHT);       //Uncheck Right Menu Item             v3
  506.   return true;                          //Return                              v6
  507. } /* end AHelloWindow :: setCenterAlignmnet() */                            //v6
  508.  
  509. //**************************************************************************  v6
  510. // AHelloWindow :: setRightAlignment()                                     *   .
  511. //   Set Right Alignment                                                   *   .
  512. //**************************************************************************   .
  513. Boolean AHelloWindow :: setRightAlignment()//Set Right Alignment               .
  514. {                                       //                                     .
  515.   hello->setAlignment(                  //Set alignment of hello text to      v3
  516.     IStaticText::centerRight);          //  center-vertical, right-horizontal  .
  517.   statusLine->setText(STR_RIGHT);       //Set Status Text to "Right" from Res  .
  518.   menuBar->uncheckItem(MI_CENTER);      //Uncheck Center Menu Item             .
  519.   menuBar->uncheckItem(MI_LEFT);        //Uncheck Left Menu Item               .
  520.   menuBar->checkItem(MI_RIGHT);         //Place Check on Right Menu Item      v3
  521.   return true;                          //Return                              v6
  522. } /* end AHelloWindow :: setRightAlignmnet() */                             //v6
  523.  
  524. //**************************************************************************  v5
  525. // AHelloWindow :: setText(...)                                            *   .
  526. //   Set Text                                                              *   .
  527. //**************************************************************************   .
  528. Boolean AHelloWindow :: setText(const char* text)//Set Text using String       .
  529. {                                       //                                     .
  530.   hello->setText(text);                 //Set Text in Control                  .
  531.   return true;                          //Return                               .
  532. } /* end AHelloWindow :: setText(...) */                                    //v5
  533.  
  534. //**************************************************************************  v6
  535. // AHelloWindow :: setText(...)                                            *   .
  536. //   Set Text                                                              *   .
  537. //**************************************************************************   .
  538. Boolean AHelloWindow :: setText(const IResourceId& text)//Set Text via RC      .
  539. {                                       //                                     .
  540.   hello->setText(text);                 //Set Text in Control                  .
  541.   return true;                          //Return                              v6
  542. } /* end AHelloWindow :: setText(...) */                                    //v6
  543.  
  544. //**************************************************************************  v6
  545. // AHelloWindow :: openFile()                                              *   .
  546. //   Open File                                                             *   .
  547. //**************************************************************************   .
  548. Boolean AHelloWindow :: openFile()      //Open File                            .
  549. {                                       //                                     .
  550.   IFileDialog::Settings fsettings;      //                                     .
  551.   fsettings.setTitle(STR_FILEDLGT);     //Set Open Dialog Title from Resource  .
  552.   fsettings.setFileName("*.hlo");       //Set FileNames to *.hlo               .
  553.  
  554.   IFileDialog fd(                       //Create File Open Dialiog             .
  555.     (IWindow*)desktopWindow(),          //  Parent is Desktop                  .
  556.     (IWindow*)this, fsettings);         //  Owner is me with settings          .
  557.   if (fd.pressedOK())                   //Check if ok from file open dialog    .
  558.   {
  559.     filename=fd.fileName();             //                                     .
  560.     if (filename.size())                //Has Filename been specified?         .
  561.     {                                   //                                     .
  562.       ifstream infile(filename);        //Input file stream                    .
  563.       if (infile)                       //Does file exist?                     .
  564.       {                                 //  Yes, File does exist               .
  565.         cin=infile.rdbuf();             //  Set cin to infile                  .
  566.         setText(                        //Set text in Static Text Control      .
  567.           IString().lineFrom(cin));     //  from the input file.               .
  568.         infile.close();                 //  Close input file                   .
  569.       }                                 //                                     .
  570.       else                              //Can not open input file              .
  571.       {                                 //                                     .
  572.         IMessageBox mbox(this);         //  Create Message Box                 .
  573.         IString msgTxt =                //Define Message Text                  .
  574.           IApplication::current().      //Get current application              .
  575.           userResourceLibrary().        //  Set the Name of Resoure DLL        .
  576.           loadString(STR_MSGTXT);       //  Create message text for rc file    .
  577.         msgTxt.change(                  //  Change Message Text to add Filename.
  578.           "$$$$$$$$$$$$$$$$$$$$",       //    Pattern,                         .
  579.           filename,                     //    Replacement,                     .
  580.           1, 1);                        //    StartPos, Number of Changes      .
  581.         mbox.show(msgTxt,               //  Display Message Box                .
  582.           IMessageBox::warning);        //  Set Warning Style                  .
  583.       }                                 //                                     .
  584.     } /* endif */                       //                                     .
  585.   } /* endif */                         //                                     .
  586.   return true;                          //Return                               .
  587. } /* end AHelloWindow :: openFile() */                                      //v6
  588.  
  589. //**************************************************************************  v6
  590. // AHelloWindow :: openFont()                                              *   .
  591. //   Open Font                                                             *   .
  592. //**************************************************************************   .
  593. Boolean AHelloWindow :: openFont()      //Open Font                            .
  594. {                                       //                                     .
  595.   IFont curFont(hello);                 //Define curFont                       .
  596.   IFontDialog::Settings fsettings(&curFont);//                                 .
  597.   fsettings.setTitle(STR_FONTDLGT);     //Set Open Dialog Title from Resource  .
  598.  
  599.   IFontDialog fontd(                    //Create Font Open Dialiog             .
  600.     (IWindow*)desktopWindow(),          //  Parent is Desktop                  .
  601.     (IWindow*)this,                     //  Owner is me                        .
  602.     (IFontDialog::defaultStyle() |      //  Set default Style with only        .
  603.     IFontDialog::bitmapOnly),           //  BitMap Fonts                       .
  604.     fsettings);                         //  settings                           .
  605.   if (fontd.pressedOK())                //Check if ok from Font open dialog    .
  606.   {                                     //                                     .
  607.     hello->setFont(curFont);            //Change hello font to be curFont      .
  608.   } /* endif */                         //                                     .
  609.   return true;                          //Return                               .
  610. } /* end AHelloWindow :: openFont() */                                      //v6
  611.  
  612. //**************************************************************************  v6
  613. // AHelloWindow :: openText()                                              *   .
  614. //   Open Text                                                             *   .
  615. //**************************************************************************   .
  616. Boolean AHelloWindow :: openText()      //Open Text Dialog                     .
  617. {                                       //                                    v6
  618.   IString temp;                         //String to pass in/out from dialog   v4
  619.   unsigned short value;                 //Return value from dialog            v4
  620.  
  621.   temp=hello->text();                   //Get current Hello text              v4
  622.   infoArea->setInactiveText(            //Set Info Area to Dialog Active       .
  623.     STR_INFODLG);                       //  Text from Resource File            .
  624.   ATextDialog * textDialog=new          //Create a Text Dialog                 .
  625.     ATextDialog(temp, this);            //                                     .
  626.   textDialog->showModally();            //Show this Text Dialog as Modal       .
  627.   value=textDialog->result();           //Get result (eg OK or Cancel)         .
  628.   if (value != DID_CANCEL)              //Set new string if not canceled       .
  629.     hello->setText(temp);               //Set Hello to Text from Dialog        .
  630.   infoArea->setText(STR_INFO);          //Set Info Text to "Normal" from Res   .
  631.   delete textDialog;                    //Delete textDialog                    .
  632.   return(true);                         //Return Command Processed            v4
  633. } /* end AHelloWindow :: openText() */                                      //v6
  634.  
  635. //**************************************************************************  v6
  636. // AHelloWindow :: tick(...)                                               *   .
  637. //   Timer Tick Message (set to every second in our sample)                *   .
  638. //**************************************************************************   .
  639. Boolean AHelloWindow::tick(IEvent& evt) //Process the Tick Message             .
  640. {                                       //                                     .
  641.   time->setText(ITime().asString());    //Set current time                     .
  642.   if ((ITime().asSeconds()) < 3)        //Is it just after midnight?           .
  643.     date->setText(IDate().asString());  //  Yes, Set current date              .
  644.   if (demo)                             //                                     .
  645.   {                                     //                                     .
  646.     demoCount = demoCount - 1;          //                                     .
  647.     if (demoCount < 1)                  //                                     .
  648.     {                                   //                                     .
  649.       nextDemoCode();                   //Execute next Demo Code               .
  650.       demoCount = demoTicks;            //Reset                                .
  651.     } /* endif */                       //                                     .
  652.   }
  653.   return true;                          //Return true                          .
  654. } /* end AHelloWindow :: stopTimer() */                                     //v6
  655.  
  656. //**************************************************************************  v6
  657. // AHelloWindow :: startDemo(...)                                          *   .
  658. //   Start Demo                                                            *   .
  659. //**************************************************************************   .
  660. Boolean AHelloWindow::startDemo()       //Process the Demo Start               .
  661. {                                       //                                     .
  662.   demo=true;                            //Set Start of Demo                    .
  663.   demoIndex = 1;                        //Set to first index                   .
  664.   demoCount = demoTicks;                //Reset                                .
  665.   menuBar->disableItem(MI_DEMO_START);  //Disable Start Menu Item              .
  666.   menuBar->enableItem(MI_DEMO_STOP);    //Enable Stop Menu Item                .
  667.   return true;                          //Return true                          .
  668. } /* end AHelloWindow :: demoStart() */                                     //v6
  669.  
  670. //**************************************************************************  v6
  671. // AHelloWindow :: stopDemo(...)                                           *   .
  672. //   Stop Demo                                                             *   .
  673. //**************************************************************************   .
  674. Boolean AHelloWindow::stopDemo()        //Process the Demo Stop                .
  675. {                                       //                                     .
  676.   demo=false;                           //Set Stop Demo                        .
  677.   menuBar->enableItem(MI_DEMO_START);   //
  678.   menuBar->disableItem(MI_DEMO_STOP);   //
  679.   return true;                          //Return true                          .
  680. } /* end AHelloWindow :: demoStop() */                                      //v6
  681.  
  682. //**************************************************************************  v6
  683. // AHelloWindow :: nextDemoCode(...)                                       *   .
  684. //   Execute the next Demo Code (Case)                                     *   .
  685. //**************************************************************************   .
  686. Boolean AHelloWindow::nextDemoCode()    //Process the Demo Code                .
  687. {                                       //                                     .
  688.   IFont tempFont;
  689.  
  690.   switch (demoIndex)                    //Process the next demo "case"         .
  691.   {                                     //                                     .
  692.   case 1:                               //                                     .
  693.     leftButton->click();                //"Click" on Left Alignment Button     .
  694.     break;                              //                                     .
  695.                                         //                                     .
  696.   case 2:                               //                                     .
  697.     rightButton->click();               //"Click" on Right Alignment Button    .
  698.     break;                              //                                     .
  699.                                         //                                     .
  700.   case 3:                               //                                     .
  701.     centerButton->click();              //"Click" on Center Alignment Button   .
  702.     break;                              //                                     .
  703.                                         //                                     .
  704.   case 4:                               //                                     .
  705.     listBox->select(1UL);               //Select Item One                      .
  706.     break;                              //                                     .
  707.                                         //                                     .
  708.   case 5:                               //                                     .
  709.     listBox->select(3UL);               //Select Item Three                    .
  710.     break;                              //                                     .
  711.                                         //                                     .
  712.   case 6:                               //                                     .
  713.     listBox->select(5UL);               //Select Item Five                     .
  714.     break;                              //                                     .
  715.                                         //                                     .
  716.   case 7:                               //                                     .
  717.     listBox->select(0UL);               //Select Item Zero                     .
  718.     break;                              //                                     .
  719.                                         //                                     .
  720.   case 8:                               //                                     .
  721.     tempFont=IFont("Helv", 12);         //Set Temp. Font                       .
  722.     hello->setFont(tempFont);           //Set Font for "Hello, World" Text     .
  723.     break;                              //                                     .
  724.                                         //                                     .
  725.   case 9:                               //                                     .
  726.     tempFont=IFont("Helv", 14);         //Set Temp. Font                       .
  727.     hello->setFont(tempFont);           //Set Font for "Hello, World" Text     .
  728.     break;                              //                                     .
  729.                                         //                                     .
  730.   case 10:                              //                                     .
  731.     tempFont=IFont("Helv", 18);         //Set Temp. Font                       .
  732.     hello->setFont(tempFont);           //Set Font for "Hello, World" Text     .
  733.     break;                              //                                     .
  734.                                         //                                     .
  735.   case 11:                              //                                     .
  736.     hello->setColor(                    //Set "Hello, world" text to black     .
  737.       IStaticText::foreground,          //                                     .
  738.       IColor(IColor::black));           //                                     .
  739.     break;                              //                                     .
  740.                                         //                                     .
  741.   case 12:                              //                                     .
  742.     hello->setColor(                    //Set "Hello, world" text to blue      .
  743.       IStaticText::foreground,          //                                     .
  744.       IColor(IColor::blue));            //                                     .
  745.     break;                              //                                     .
  746.                                         //                                     .
  747.   case 13:                              //                                     .
  748.     hello->setColor(                    //Set "Hello, world" text to red       .
  749.       IStaticText::foreground,          //                                     .
  750.       IColor(IColor::red));             //                                     .
  751.     break;                              //                                     .
  752.                                         //                                     .
  753.   case 14:                              //                                     .
  754.     hello->setColor(                    //Set "Hello, world" text to pink      .
  755.       IStaticText::foreground,          //                                     .
  756.       IColor(IColor::pink));            //                                     .
  757.     break;                              //                                     .
  758.                                         //                                     .
  759.   case 15:                              //                                     .
  760.     hello->setColor(                    //Set "Hello, world" text to green     .
  761.       IStaticText::foreground,          //                                     .
  762.       IColor(IColor::green));           //                                     .
  763.     break;                              //                                     .
  764.                                         //                                     .
  765.   case 16:                              //                                     .
  766.     hello->setColor(                    //Set "Hello, world" text to cyan      .
  767.       IStaticText::foreground,          //                                     .
  768.       IColor(IColor::cyan));            //                                     .
  769.     break;                              //                                     .
  770.                                         //                                     .
  771.   case 17:                              //                                     .
  772.     hello->setColor(                    //Set "Hello, world" text to yellow    .
  773.       IStaticText::foreground,          //                                     .
  774.       IColor(IColor::yellow));          //                                     .
  775.     break;                              //                                     .
  776.                                         //                                     .
  777.   case 18:                              //                                     .
  778.     hello->setColor(                    //Set "Hello, world" text to blue      .
  779.       IStaticText::foreground,          //                                     .
  780.       IColor(IColor::blue));            //                                     .
  781.     break;                              //                                     .
  782.                                         //                                     .
  783.   case 19:                              //                                     .
  784.     clientWindow->setSplitWindowPercentage(//Set the Window Percentage for     .
  785.       helloCanvas, 40);                 //  the helloCanvas to 40              .
  786.     clientWindow->setSplitWindowPercentage(//Set the Window Percentage for     .
  787.       listBox, 60);                     //  the listBox to 60                  .
  788.     clientWindow->refresh();            //                                     .
  789.     break;                              //                                     .
  790.                                         //                                     .
  791.   case 20:                              //                                     .
  792.     clientWindow->setSplitWindowPercentage(//Set the Window Percentage for     .
  793.       helloCanvas, 60);                 //  the helloCanvas to 60              .
  794.     clientWindow->setSplitWindowPercentage(//Set the Window Percentage for     .
  795.       listBox, 40);                     //  the listBox to 40                  .
  796.     clientWindow->refresh();            //                                     .
  797.     break;                              //                                     .
  798.                                         //                                     .
  799.   case 21:                              //                                     .
  800.     demoIndex=0;                        //Reset to start                       .
  801.     break;                              //                                     .
  802.                                         //                                     .
  803.   } /* endswitch */                     //                                     .
  804.   demoIndex = demoIndex + 1;            //                                     .
  805.   return true;                          //Return true                          .
  806. } /* end AHelloWindow :: demoStop() */                                      //v6
  807.  
  808. //**************************************************************************  v6
  809. // AHelloWindow :: openColor()                                             *   .
  810. //**************************************************************************   .
  811. Boolean AHelloWindow :: openColor()     //                                     .
  812. {                                       //                                     .
  813.   color=new AColorWindow(hello,         //Open Color Window                    .
  814.     listBox, this);                     //                                     .
  815.   return true;                          //                                     .
  816. } /* end AHelloWindow :: openColor() */                                     //v6
  817.  
  818. //**************************************************************************  v6
  819. // AHelloWindow :: openSpeed()                                             *   .
  820. //**************************************************************************   .
  821. Boolean AHelloWindow :: openSpeed()     //                                     .
  822. {                                       //                                     .
  823.   new ASpeedWindow(this, this);         //Open Demo Speed Window               .
  824.   return true;                          //                                     .
  825. } /* end AHelloWindow :: openSpeed() */                                     //v6
  826.  
  827. //**************************************************************************  v6
  828. // AHelloWindow :: readProfile()                                           *   .
  829. //**************************************************************************   .
  830. Boolean AHelloWindow :: readProfile()   //                                     .
  831. {                                       //                                     .
  832.   try                                   //                                     .
  833.   {                                     //                                     .
  834.     IProfile profile("HELLO6.INI");     //Define Profile Object                .
  835.     profile.setDefaultApplicationName(  //Define Application Name              .
  836.       "Hello6");                        //                                     .
  837.     demoTicks=profile.                  //Get Demo Speed From Profile          .
  838.       integerWithKey("Speed");          //                                     .
  839.     IString face=profile.               //Get Font Face                        .
  840.       elementWithKey("FontFace");       //  using "FontFace" Key               .
  841.     int size=profile.                   //Get Font Size                        .
  842.       integerWithKey("FontSize");       //  using "FontSize" Key               .
  843.     IFont tempFont(face, size);         //Create Temp. Font                    .
  844.     hello->setFont(tempFont);           //Set Font for "Hello, World" Text     .
  845.   }                                     //                                     .
  846.   catch (IException& exc)               //Catch Error trying to open profile   .
  847.   {                                     //                                     .
  848.     DosBeep(750,500);                   //Report Error via beep                .
  849.     IMessageBox mbox(this);             //  Create Message Box                 .
  850.     mbox.show(exc);                     //                                     .
  851.     return false;                       //Return could not open profile        .
  852.   }                                     //                                     .
  853.   return true;                          //                                     .
  854. } /* end AHelloWindow :: readProfile() */                                   //v6
  855.  
  856. //**************************************************************************  v6
  857. // AHelloWindow :: updateProfile()                                         *   .
  858. //**************************************************************************   .
  859. Boolean AHelloWindow :: updateProfile() //                                     .
  860. {                                       //                                     .
  861.   try                                   //                                     .
  862.   {                                     //                                     .
  863.     IProfile profile("HELLO6.INI");     //Define Profile Object                .
  864.     profile.setDefaultApplicationName(  //Set Default Application Name to      .
  865.       "Hello6");                        //  Hello6                             .
  866.     profile.addOrReplaceElementWithKey( //Update Profile with                  .
  867.       "Speed", (long)speed());          //  Speed from current demo speed      .
  868.     IFont tempFont(hello);              //Get current Font for hello           .
  869.     profile.addOrReplaceElementWithKey( //Update Profile with                  .
  870.       "FontFace", tempFont.name());     //  FontFace from current hello font   .
  871.     profile.addOrReplaceElementWithKey( //Update Profile with                  .
  872.       "FontSize",                       //  FontSize from                      .
  873.       (long)tempFont.pointSize());      //  from current hello font            .
  874.   }                                     //                                     .
  875.   catch (IException& exc)               //Catch Error trying to open profile   .
  876.   {                                     //                                     .
  877.     DosBeep(750,500);                   //Report Error via beep                .
  878.     IMessageBox mbox(this);             //  Create Message Box                 .
  879.     mbox.show(exc);                     //                                     .
  880.     return false;                       //Return failure                       .
  881.   }                                     //                                     .
  882.   return true;                          //                                     .
  883. } /* end AHelloWindow :: updateProfile() */                                 //v6
  884.  
  885. //**************************************************************************  v6
  886. // AMenuHandler :: makePopUpMenu                                           *   .
  887. //**************************************************************************   .
  888. IPopUpMenu * AMenuHandler :: makePopUpMenu(const IMenuEvent& mnEvt) //         .
  889. {                                       //                                     .
  890.   IPopUpMenu * popUp;                   //Define popUp variable                .
  891.   popUp=new IPopUpMenu(WND_POPUP,       //Create PopUp Menu with AutoDelete on .
  892.               mnEvt.window());          //                                     .
  893.   popUp->show(mnEvt.mousePosition());   //Show PopUp Menu                      .
  894.   return popUp;                         //Return PopUp Menu                    .
  895. } /* end AMenuHandler :: makePopUpMenu(...) */                              //v6
  896.  
  897. //**************************************************************************  v5
  898. // AHelpHandler :: keysHelpId                                              *   .
  899. //   Handle the keys help request event                                    *   .
  900. //   This overrides the default provided by IBMCLASS                       *   .
  901. //**************************************************************************   .
  902. Boolean AHelpHandler :: keysHelpId(IEvent& evt)  //                            .
  903. {                                                //                            .
  904.   evt.setResult(1000);                           //1000=keys help id in        .
  905.                                                  //  ahellow6.ipf file         .
  906.   return true;                                   //Return command processed    .
  907. } /* end AHelpHandler :: keysHelpId(...) */                                 //v5
  908.