home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
wclass.zip
/
CPPAPP.CPP
< prev
next >
Wrap
Text File
|
1994-04-25
|
4KB
|
130 lines
/*----------------------------------------------------------------------------*/
/* (c) 1993, 1994 Larry Morley / Enlightened Computer Solutions */
/*----------------------------------------------------------------------------*/
/* module: cppapp.cpp created_on: 5 May 1993 by: LJM */
/* desc : Application sample using framework library 'classlib.cpp' */
/* complr: icc /Fi /Fd /c /Ss /Sp1 /Gm+ /G4 /Kb+ [/Ti+ intrnl, /Ti- rel] */
/* lnkr : link386 /a:4 [/deb intrnl,rel=<none> /base:65536 /noe */
/* rc $*.res */
/* etc : rc -r $*.rc */
/* mkfile: makefile */
/* depend: (see makefile) */
/* mhist : */
/*----------------------------------------------------------------------------*/
#define INCL_WIN
#define INCL_DOS
#define INCL_GPI
#include <os2.h>
#include "cppapp.hpp"
#include "classlib.hpp"
#include <stdio.h>
/*----------------------------------------------------------------------------*/
// Get access to the status / message / whatever line's text
extern char szStatLineText[];
/*----------------------------------------------------------------------------*/
// Declare a window class
class MyWindow : public Window
{
public:
MRESULT PaintEventHandler(HWND,ULONG,MPARAM,MPARAM);
MRESULT CommandEventHandler(HWND,ULONG,MPARAM,MPARAM);
MRESULT MenuSelectEventHandler(HWND,ULONG,MPARAM,MPARAM);
};
/*----------------------------------------------------------------------------*/
// Set up event handlers for all events I chose above
MRESULT MyWindow ::
PaintEventHandler(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
HPS hPS;
RECTL rcl;
POINTL ptl;
int i;
int j;
hPS = WinBeginPaint(hwnd,(HPS)0,&rcl);
GpiErase(hPS);
for (i=0,j=640;i<640;i+=5,j-=5)
{
ptl.x = i;
ptl.y = 0;
GpiMove(hPS,&ptl);
ptl.x = j;
ptl.y = 480;
GpiLine(hPS,&ptl);
}
WinEndPaint(hPS);
return (MRESULT)0;
}
/*----------------------------------------------------------------------------*/
MRESULT MyWindow ::
CommandEventHandler(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
switch ((int)mp1)
{
case IDM_FILE_ABOUT:
WinMessageBox(
HWND_DESKTOP,
HWND_DESKTOP,
"C++ Application",
"About",
999,
MB_OK);
break;
}
return (MRESULT)0;
}
/*----------------------------------------------------------------------------*/
MRESULT MyWindow::
MenuSelectEventHandler(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
char *p;
p = new char [80];
if (p)
{
sprintf(
szStatLineText,
"*** Menu Option %5u selected ***",
SHORT1FROMMP(mp1));
delete[] p;
WinInvalidateRect(hwndStatus,(PRECTL)0,TRUE);
}
return WinDefWindowProc(hwnd,msg,mp1,mp2);
}
/*----------------------------------------------------------------------------*/
// Create a new App, a Window, then run the App.
int main()
{
App *p;
MyWindow *w;
p = new App;
w = new MyWindow;
if (w->Create())
p->Run();
delete w;
delete p;
return 0;
}
/*----------------------------------------------------------------------------*/