home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ICLUI.ZIP / HELLO2 / AHELLOW2.CPP next >
Text File  |  1993-03-06  |  5KB  |  78 lines

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 2: Class Implementation (AHELLOW2.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.                                         //Include the IBM UI class headers:
  33. #include <iapp.hpp>                     //IApplication class
  34. #include <istattxt.hpp>                 //IStaticText class
  35. #include <iinfoa.hpp>                   //IInfoArea Class                     v2
  36.  
  37. #include "ahellow2.hpp"                 //Include the AHelloWindow class      v2
  38.                                         //  header                            v2
  39. #include "ahellow2.h"                   //Include our symbolic definitions    v2
  40.  
  41. //*************************************************************************
  42. // main  - Application entry point                                        *
  43. //*************************************************************************
  44. void main()                             //Main procedure with no parameters
  45. {
  46.   AHelloWindow mainWindow (WND_MAIN);   //Create our main window on the
  47.                                         // desktop
  48.   IApplication::current().run();        //Get the current application and
  49.                                         // run it
  50. } /* end main */
  51.  
  52. //**************************************************************************
  53. // AHelloWindow :: AHelloWindow - Constructor for our main window          *
  54. //**************************************************************************
  55. AHelloWindow :: AHelloWindow(unsigned long windowId)
  56.   : IFrameWindow (                      //Call the IFrameWindow constructor
  57.     IFrameWindow::defaultStyle()        //  using the default style, plus     v2
  58.     | IFrameWindow::minimizedIcon,      //  get minimized icon from RC file   v2
  59.     windowId)                           //  and set the main window ID
  60. {
  61.   hello=new IStaticText(WND_HELLO,      //Create a static text control
  62.     this, this);                        //  Pass in this AHelloWindow as the
  63.                                         //  owner and parent of the control
  64.   hello->setText(STR_HELLO);            //Set text in the static text control v2
  65.                                         // from the RC file                   v2
  66.   hello->setAlignment(                  //Set the alignment to center in both
  67.     IStaticText::centerCenter);         // directions
  68.   setClient(hello);                     //Set the static text control as the
  69.                                         // client window
  70.   infoArea=new IInfoArea(this);         //Create the information area         v2
  71.   infoArea->setInactiveText(STR_INFO);  //Set information area text from RC   v2
  72.  
  73.   sizeTo(ISize(400,300));               //Set the pixel size of main window   v2
  74.   setFocus();                           //Set the focus to the main window
  75.   show();                               //Show the main window
  76.  
  77. } /* end AHelloWindow :: AHelloWindow(...) */
  78.