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 >
Wrap
C/C++ Source or Header
|
1995-04-07
|
7KB
|
96 lines
/*****************************************************************************
* HELLO WORLD SAMPLE PROGRAM - Version 2: Class Implementation (ahellow2.cpp)*
* *
* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1995. *
* *
* DISCLAIMER OF WARRANTIES: *
* The following [enclosed] code is sample code created by IBM *
* Corporation. This sample code is not part of any standard IBM product *
* and is provided to you solely for the purpose of assisting you in the *
* development of your applications. The code is provided "AS IS", *
* without warranty of any kind. IBM shall not be liable for any damages *
* arising out of your use of the sample code, even if they have been *
* advised of the possibility of such damages. *
*****************************************************************************/
//NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
/************************************************************************** V1
* C++ Hello World History and Key Functions: * V1
* Version 1: (lines with V1 in column 79-80) * V1
* - Creates and runs a simple application * V1
* - Creates the main window (IFrameWindow) * V1
* - Creates a static text control set to "Hello, World!!!" as the * V1
* client window * V1
* * V2
* Version 2: (lines with V2 in column 79-80) * V2
* - Creates a main window (AHellowWindow) derived from IFrameWindow * V2
* - Gets the "Hello, World!!!" text string and other items from a * V2
* resource file * V2
* - Sets the window title from a resource file * V2
* - Creates and sets the information area below the client window * V2
**************************************************************************/
//Include User Interface Class Library class headers:
#ifndef _IBASE_ //Make sure ibase.hpp is included
#include <ibase.hpp> // since that is where IC_<environ>
#endif // is defined.
#include <iapp.hpp> //IApplication class V1
#include "ahellow2.hpp" //Include AHelloWindow class headers v2
#include "ahellow2.h" //Include symbolic definitions v2
/************************************************************************** V1
* main - Application entry point for Hello World Version 2. * v2
* This simple application does the following: * V1
* 1) Creates a new object mainWindow of class AHelloWindow * V1
* 2) Sets the size of mainWindow * V1
* 3) Sets the window focus to mainWindow * V1
* 4) Displays the mainWindow * V1
* 5) Starts the events processing for the application * V1
**************************************************************************/
int main() //V1
{ //V1
AHelloWindow mainWindow (WND_MAIN); //V2
mainWindow.sizeTo(ISize(400,300)); //V1
mainWindow.setFocus(); //V1
mainWindow.show(); //V1
IApplication::current().run(); //V1
return 0;
} /* end main */ //V1
/************************************************************************** V2
* AHelloWindow :: AHelloWindow - Constructor for the main window * V2
* Construct the IFrameWindow using the default style plus minimizedIcon, * V2
* which gets the Icon identified in the resource file and associates it * V2
* with the main window. * V2
* Create the hello world static text to be used as the client window. * V2
* Create the Hello World information area object from IInfoArea class. * V2
* The information area is automatically added as an extension below * V2
* the client window of the frame. * V2
**************************************************************************/ //V2
AHelloWindow :: AHelloWindow(unsigned long windowId) //V2
: IFrameWindow(IFrameWindow::defaultStyle() | //V2
IFrameWindow::minimizedIcon, //V2
windowId) //V2
,hello(WND_HELLO, this, this) //V2
,infoArea(this) //V2
{ //V2
/*------------------------- Setup the Client Window ----------------------| V2
| Set the hello world static text window as the client window. | V2
|------------------------------------------------------------------------*/ //V2
setClient(&hello); //V2
/*---------------------------- Set Text Values ---------------------------| V2
| Set the values for the text controls from strings in the resource file.| V2
| The infoArea inactive text is displayed when no menu item is active. | V2
|------------------------------------------------------------------------*/ //V2
hello.setText(STR_HELLO); //V2
infoArea.setInactiveText(STR_INFO); //V2
/*----------------------- Set Default Alignment --------------------------| V2
| Align the static text in the client window. | V2
|------------------------------------------------------------------------*/ //V2
hello.setAlignment(IStaticText::centerCenter); //V2
} /* end AHelloWindow :: AHelloWindow(...) */ //V2