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