1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/*************************************************************
* The Application Class
*************************************************************/
class CApplication
{
private:
/* Member Variables */
HWND hWnd;
HWND editMain;
/* Member Methods */
static LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
bool CreateControls( HWND hWnd, HINSTANCE hInst );
// Making this function static causes a problem with the member
// variables... Making them static as well causes also an error!
public:
/* Member Methods */
CApplication( void );
~CApplication( void );
bool Init( HINSTANCE hInst );
inline HWND GetMainWnd( void );
};
/*************************************************************
* Message Handler
*************************************************************/
LRESULT CALLBACK CApplication::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
CApplication appTmp;
switch( msg ) {
case WM_CREATE:
{
appTmp.CreateControls( hWnd, ((LPCREATESTRUCT)lParam)->hInstance );
break;
}
case WM_CLOSE:
case WM_DESTROY:
{
PostQuitMessage( 0 );
break;
}
default:
{
return DefWindowProc( hWnd, msg, wParam, lParam );
}
}
return 0;
}
/*************************************************************
* Create the controls
*************************************************************/
bool CApplication::CreateControls( HWND hWnd, HINSTANCE hInst ) {
editMain = CreateWindowEx( WS_EX_CLIENTEDGE, "edit", "Test",
WS_CHILD | WS_VISIBLE | WS_BORDER |
ES_MULTILINE |
WS_HSCROLL | WS_VSCROLL,
0, 0, 600, 400,
hWnd, (HMENU)IDM_EDIT_TEST, hInst, NULL );
if( !editMain )
return false;
return true;
}
|