#include LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { MSG Msg; HWND hWnd; HRESULT hResult; WNDCLASSEX WndClsEx; // Populate the WNDCLASSEX structure WndClsEx.cbSize = sizeof(WNDCLASSEX); WndClsEx.style = CS_VREDRAW | CS_HREDRAW; WndClsEx.lpfnWndProc = WndProcedure; WndClsEx.cbClsExtra = 0; WndClsEx.cbWndExtra = 0; WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW); WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndClsEx.lpszMenuName = NULL; WndClsEx.lpszClassName = "TEST"; WndClsEx.hInstance = hInstance; WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // Register the class RegisterClassEx(&WndClsEx); // Create the window object hWnd = CreateWindow("TEST", "TEST", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); // Verify window creation if(!hWnd) // If the window was not created, return 0; // stop the application // Show the window ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); // Message Pump while((hResult = GetMessage(&Msg, NULL, 0, 0)) != 0) { if(hResult == -1) { // handle the error and possible exit } else { TranslateMessage(&Msg); DispatchMessage(&Msg); } } } LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_DESTROY: // user wants to exit PostQuitMessage(WM_QUIT); break; default: // Hand off unprocessed messages to DefWindowProc return DefWindowProc(hWnd, Msg, wParam, lParam); } }