home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
mag&info
/
msjv7_5.zip
/
WINCPP.ARJ
/
CPP3.ARJ
/
WINAPP.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-01
|
4KB
|
133 lines
// WinApp.h RHS 4/15/92
#if !defined(WINAPP_H)
#define WINAPP_H
#include<windows.h>
extern HINSTANCE WinApphInstance;
extern HINSTANCE WinApphPrevInstance;
extern LPSTR WinApplpCmdLine;
extern int WinAppnCmdShow;
class Window; // class declarations
class WinApp;
class Window
{
protected:
HWND hWnd;
public:
Window(HWND newhWnd = 0)
{
hWnd = newhWnd;
}
~Window(){}
BOOL RegisterClass(UINT style,WNDPROC WndProc,int ClsExtra,
int WndExtra,HINSTANCE inst,HICON icon,HCURSOR cursor,
HBRUSH brush,LPCSTR menuname,LPCSTR classname)
{
WNDCLASS wc;
wc.style = style;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = ClsExtra;
wc.cbWndExtra = WndExtra;
wc.hInstance = inst;
wc.hIcon = icon;
wc.hCursor = cursor;
wc.hbrBackground = brush;
wc.lpszMenuName = menuname;
wc.lpszClassName = classname;
return ::RegisterClass(&wc);
}
BOOL RegisterClass(
UINT style,
WNDPROC WndProc,
LPCSTR menuname,
LPCSTR classname,
HICON icon = LoadIcon(NULL, IDI_APPLICATION),
HCURSOR cursor = LoadCursor(NULL, IDC_ARROW),
HBRUSH brush = GetStockObject(WHITE_BRUSH))
{
return RegisterClass(style,WndProc,0,0,WinApphInstance,icon,cursor,
brush,menuname,classname);
}
BOOL CreateWindow(LPCSTR classname,LPCSTR text,DWORD style,int x,int y,
int width,int height,HWND parent,HMENU menu,HINSTANCE inst,
void FAR *params)
{
if(hWnd = ::CreateWindow(classname,text,style,x,y,width,height,
parent,menu,inst,params))
return TRUE;
return FALSE;
}
BOOL CreateWindow(
LPCSTR classname,
LPCSTR text,
DWORD style,
HWND parent = NULL,
HMENU menu = NULL)
{
return CreateWindow(classname,text,style,
CW_USEDEFAULT, // Default position.
CW_USEDEFAULT, // Default position.
CW_USEDEFAULT, // Default position.
CW_USEDEFAULT, // Default position.
parent,menu,WinApphInstance,NULL);
}
BOOL ShowWindow(int cmdshow = WinAppnCmdShow)
{
return ::ShowWindow(hWnd,cmdshow);
}
void UpdateWindow(void)
{
::UpdateWindow(hWnd);
}
};
extern WinApp *pWinApp;
class WinApp
{
public:
Window *mainWnd;
// constructor -- initializes data members
WinApp(void) : mainWnd(NULL)
{
#if defined(DEBUG)
assert(pWinApp == NULL); // only one WinApp object allowed
#endif
pWinApp = this; // initialize WinApp pointer
}
~WinApp(){} // virtual destructor, allows overriding
// functions to access data members
HINSTANCE Instance(void) { return WinApphInstance; }
HINSTANCE PrevInstance(void) { return WinApphPrevInstance; }
LPSTR CmdLine(void) { return WinApplpCmdLine; }
int CmdShow(void) { return WinAppnCmdShow; }
void Init(HINSTANCE hInst,HINSTANCE hPrev,LPSTR cmdLine,int cmdShow)
{
WinApphInstance = hInst;
WinApphPrevInstance = hPrev;
WinApplpCmdLine = cmdLine;
WinAppnCmdShow = cmdShow;
}
virtual BOOL InitApplication(void) { return TRUE; }
virtual BOOL InitInstance(void) { return TRUE; }
};
BOOL FAR PASCAL About(HWND hWnd, LPCSTR resoureName);
#endif