// Win32 기본창 출력
#include <Windows.h>
#include <tchar.h>
HINSTANCE g_hInst = NULL;
void InitWndClass( HINSTANCE hInstance, LPCTSTR lpszClassName );
int MessageRun( void );
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam );
//////////////////////////////////////////////////////////////////////////
// hPrevInstance=16비트 윈도우의 잔재로 항상 NULL값을 가지고 사용하지 않는다.
int APIENTRY _tWinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPTSTR lpCmdLine, __in int nShowCmd )
{
const LPCTSTR lpszClassName = _T("x108zero");
g_hInst = hInstance;
// Window Class Struct에 값 입력
InitWndClass( hInstance, lpszClassName );
// Windows 생성
HWND hWnd = CreateWindow( lpszClassName, lpszClassName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, (HMENU)NULL, hInstance, NULL );
if( NULL == hWnd )
{
MessageBox( hWnd, _T("Window Create Error"), _T("Error"), MB_OK );
return -1;
}
ShowWindow( hWnd, nShowCmd );
// 메시지 처리
int nMessage = MessageRun();
return nMessage;
}
//////////////////////////////////////////////////////////////////////////
void InitWndClass( HINSTANCE hInstance, LPCTSTR lpszClassName )
{
WNDCLASS WndClass;
ZeroMemory( &WndClass, sizeof(WndClass) );
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
WndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
WndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClassName;
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass( &WndClass ); // Window Class 등록
}
//////////////////////////////////////////////////////////////////////////
int MessageRun( void )
{
MSG Message;
ZeroMemory( &Message, sizeof(Message) );
while( GetMessage( &Message, NULL, 0, 0 ) )
{
TranslateMessage( &Message );
DispatchMessage( &Message );
} // end of while( GetMessage( &Message, NULL, 0, 0 ) )
return (int)Message.wParam;
}
//////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
{
switch( iMessage )
{
case WM_CREATE:
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
ZeroMemory( &ps, sizeof(ps) );
HDC hDC = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
}
return 0;
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
} // end of switch( iMessage )
return DefWindowProc( hWnd, iMessage, wParam, lParam );
}
댓글 없음:
댓글 쓰기