home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / HELLO2 / AHELLOW2.CPP next >
C/C++ Source or Header  |  1995-04-07  |  7KB  |  96 lines

  1. /*****************************************************************************
  2. * HELLO WORLD SAMPLE PROGRAM - Version 2: Class Implementation (ahellow2.cpp)*
  3. *                                                                            *
  4. * COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1995. *
  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. /**************************************************************************   V1
  17. * C++ Hello World History and Key Functions:                              *   V1
  18. *   Version 1: (lines with V1 in column 79-80)                            *   V1
  19. *      - Creates and runs a simple application                            *   V1
  20. *      - Creates the main window (IFrameWindow)                           *   V1
  21. *      - Creates a static text control set to "Hello, World!!!" as the    *   V1
  22. *         client window                                                   *   V1
  23. *                                                                         *   V2
  24. *   Version 2: (lines with V2 in column 79-80)                            *   V2
  25. *      - Creates a main window (AHellowWindow) derived from IFrameWindow  *   V2
  26. *      - Gets the "Hello, World!!!" text string and other items from a    *   V2
  27. *         resource file                                                   *   V2
  28. *      - Sets the window title from a resource file                       *   V2
  29. *      - Creates and sets the information area below the client window    *   V2
  30. **************************************************************************/
  31. //Include User Interface Class Library class headers:
  32. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  33.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  34. #endif                                  //  is defined.
  35. #include <iapp.hpp>                     //IApplication class                  V1
  36.  
  37. #include "ahellow2.hpp"                 //Include AHelloWindow class headers  v2
  38. #include "ahellow2.h"                   //Include symbolic definitions        v2
  39.  
  40. /**************************************************************************   V1
  41. * main  - Application entry point for Hello World Version 2.              *   v2
  42. *         This simple application does the following:                     *   V1
  43. *           1) Creates a new object mainWindow of class AHelloWindow      *   V1
  44. *           2) Sets the size of mainWindow                                *   V1
  45. *           3) Sets the window focus to mainWindow                        *   V1
  46. *           4) Displays the mainWindow                                    *   V1
  47. *           5) Starts the events processing for the application           *   V1
  48. **************************************************************************/
  49. int main()                                                                  //V1
  50. {                                                                           //V1
  51.   AHelloWindow mainWindow (WND_MAIN);                                       //V2
  52.   mainWindow.sizeTo(ISize(400,300));                                        //V1
  53.   mainWindow.setFocus();                                                    //V1
  54.   mainWindow.show();                                                        //V1
  55.   IApplication::current().run();                                            //V1
  56.   return 0;
  57. } /* end main */                                                            //V1
  58.  
  59. /**************************************************************************   V2
  60. * AHelloWindow :: AHelloWindow - Constructor for the main window          *   V2
  61. * Construct the IFrameWindow using the default style plus minimizedIcon,  *   V2
  62. *   which gets the Icon identified in the resource file and associates it *   V2
  63. *   with the main window.                                                 *   V2
  64. * Create the hello world static text to be used as the client window.     *   V2
  65. * Create the Hello World information area object from IInfoArea class.    *   V2
  66. *   The information area is automatically added as an extension below     *   V2
  67. *   the client window of the frame.                                       *   V2
  68. **************************************************************************/ //V2
  69.  
  70. AHelloWindow :: AHelloWindow(unsigned long windowId)                        //V2
  71.   : IFrameWindow(IFrameWindow::defaultStyle() |                             //V2
  72.                  IFrameWindow::minimizedIcon,                               //V2
  73.                  windowId)                                                  //V2
  74.    ,hello(WND_HELLO, this, this)                                            //V2
  75.    ,infoArea(this)                                                          //V2
  76. {                                                                           //V2
  77.  
  78. /*------------------------- Setup the Client Window ----------------------|   V2
  79. |  Set the hello world static text window as the client window.           |   V2
  80. |------------------------------------------------------------------------*/ //V2
  81.   setClient(&hello);                                                        //V2
  82.  
  83. /*---------------------------- Set Text Values ---------------------------|   V2
  84. |  Set the values for the text controls from strings in the resource file.|   V2
  85. |    The infoArea inactive text is displayed when no menu item is active. |   V2
  86. |------------------------------------------------------------------------*/ //V2
  87.   hello.setText(STR_HELLO);                                                 //V2
  88.   infoArea.setInactiveText(STR_INFO);                                       //V2
  89.  
  90. /*----------------------- Set Default Alignment --------------------------|   V2
  91. | Align the static text in the client window.                             |   V2
  92. |------------------------------------------------------------------------*/ //V2
  93.   hello.setAlignment(IStaticText::centerCenter);                            //V2
  94.  
  95. } /* end AHelloWindow :: AHelloWindow(...) */                               //V2
  96.