자꾸 치기 귀찮은 윈도우즈 기본으로 만들기!
~cpp #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <windows.h> LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; HWND hWnd; WNDCLASS wc; wc.lpszClassName = "DXTEST"; wc.lpfnWndProc = WndProc; wc.style = CS_VREDRAW | CS_HREDRAW; wc.hInstance = hInstance; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH) (GetStockObject(BLACK_BRUSH)); wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; RegisterClass( &wc ); hWnd = CreateWindowEx( 0, "DXTEST", "DXTEST", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); while(true) { if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { if( 0 == GetMessage(&msg, NULL, 0, 0 ) ) { // WM_QUIT was posted, so exit return (int)msg.wParam; } // Translate and dispatch the message TranslateMessage( &msg ); DispatchMessage( &msg ); } else { // 이곳엔 메세지를 받지 않았을때 하는 일을 적어준다. // 그래픽 표시라던지.. 기타 등등.. } } return (int)msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, msg, wParam, lParam); }