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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#pragma once
#include "ClockGear.h"
/*
The order of the definition is the same as declared in AppDX9.h
*/
LRESULT AppDX9::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
AppDX9* pApp = NULL;
if( msg == WM_NCCREATE )
SetWindowLongPtr( hWnd, GWL_USERDATA, (long)(LPCREATESTRUCT(lParam)->lpCreateParams ) );
pApp = ( AppDX9* ) GetWindowLongPtr( hWnd, GWL_USERDATA );
switch( msg )
{
case WM_DESTROY:
// pApp->Destroy();
PostQuitMessage(0);
return 0;
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
AppDX9::AppDX9( const wchar_t* pcCaption )
{
WNDCLASSEX wc;
ZeroMemory( &wc, sizeof( WNDCLASSEX ));
wc.cbSize = sizeof( WNDCLASSEX );
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = GetModuleHandle( NULL );
wc.lpszClassName= (LPCUWSTR) pcCaption;
if( !RegisterClassEx( &wc ))
{
MessageBox( NULL, L" Failed to register Class! ", L"Error! ClockGear-Engine ", MB_OK );
return;
}
}
HWND AppDX9::Create( const wchar_t* pcTitle,
const int nWidth,
const int nHeight,
const int nCBit,
bool bFullscreen )
{
this->m_hWnd = CreateWindowEx( NULL,
(LPCWSTR) pcTitle,
(LPCWSTR) pcTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
nWidth,
nHeight,
NULL,
NULL,
GetModuleHandle( NULL ),
this );
ShowWindow( this->m_hWnd, SW_SHOWDEFAULT );
return this->m_hWnd;
}
void AppDX9::Destroy()
{
DestroyWindow( this->m_hWnd );
return;
}
int AppDX9::Exec()
{
MSG* pMsg = new MSG;
while( PeekMessage( pMsg, this->m_hWnd, 0, 0, PM_REMOVE ))
{
TranslateMessage( pMsg );
DispatchMessage( pMsg );
}
if( pMsg->message == WM_DESTROY )
return -1;
return 0;
}
|