2017년 9월 2일 토요일

[Win32] 시작코드

#include <windows.h> 
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,  LPSTR lpszArg, int nCmdShow) 

HWND hWnd; 
MSG msg; 
WNDCLASS WndClass;
WndClass.style = NULL; 
WndClass.lpfnWndProc = WndProc; 
WndClass.cbClsExtra = 0; 
WndClass.cbWndExtra = 0; 
WndClass.hInstance = hInstance; 
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); 
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); 
WndClass.lpszMenuName = NULL; 
WndClass.lpszClassName = "Hello"; 

if(!RegisterClass(&WndClass)) return NULL; 

hWnd = CreateWindow( 
"Hello", 
"My", 
WS_OVERLAPPEDWINDOW, 
CW_USEDEFAULT, 
CW_USEDEFAULT, 
CW_USEDEFAULT, 
CW_USEDEFAULT, 
NULL, NULL, hInstance, 
NULL 
);
 
ShowWindow(hWnd, nCmdShow); 
UpdateWindow(hWnd); 

while(GetMessage(&msg, NULL, 0, 0)) 

TranslateMessage(&msg); 
DispatchMessage(&msg); 

return msg.wParam; 
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT mesg, WPARAM wParam, LPARAM lParam)

switch(mesg) 
{
case WM_DESTROY : 
PostQuitMessage(0); 
return FALSE; 

return DefWindowProc(hWnd, mesg, wParam, lParam); 


댓글 없음:

댓글 쓰기