Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have made your code work. Basically what I do when using the WNDCLASS (or WNDCLASSEX) structure is use all parameters to be sure not to miss something. </p> <pre><code>//Include the windows header #include &lt;Windows.h&gt; //Forward declaration of the WndProc function LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); //Main entry point int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { //Window class name const wchar_t windowName[] = L"Window Class"; //Set up window class WNDCLASS wnd; wnd.cbClsExtra = 0; wnd.cbWndExtra = 0; wnd.hCursor = LoadCursor(0, IDC_ARROW); wnd.hIcon = LoadIcon(0, IDI_WINLOGO); wnd.lpszMenuName = 0; wnd.style = 0; wnd.hbrBackground = 0; wnd.lpfnWndProc = WndProc; wnd.hInstance = hInstance; wnd.lpszClassName = windowName; //Register window class RegisterClass(&amp;wnd); //Create window //! This returns NULL HWND hWnd = CreateWindowEx( 0, windowName, L"Windows Programming", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); //Simple check to see if window creation failed if(hWnd == NULL) { //Pause system("PAUSE"); return -1; } //Show the window ShowWindow(hWnd, nCmdShow); //Main message loop MSG msg; while(GetMessage(&amp;msg, NULL, 0, 0)) { TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } } //WndProc function LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDc = BeginPaint(hWnd, &amp;ps); FillRect(hDc, &amp;ps.rcPaint, (HBRUSH) (COLOR_WINDOW + 1)); EndPaint(hWnd, &amp;ps); return 0; } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, msg, wParam, lParam); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload