Note that there are some explanatory texts on larger screens.

plurals
  1. POWin32 API window won't open
    primarykey
    data
    text
    <p>okay, so I have taken out the time to learn a but of the Win32 API to do with opening windows, and the code I came up with in the end I would think would work, but doesn't. I registered the window class, made all the things I have to, but when I run it, nothing happens... It would be a great help if someone could point out what I am doing wrong/missing. </p> <pre><code>#include &lt;stdlib.h&gt; #include &lt;iostream&gt; #include &lt;Windows.h&gt; #pragma comment (lib, "wsock32.lib") #define WNDCLASSNAME "wndclass" bool quit = false; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd) { WNDCLASSEX WCE; WCE.cbSize = sizeof(WNDCLASSEX); WCE.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC|CS_DBLCLKS; WCE.lpfnWndProc = WndProc; WCE.cbClsExtra = 0; WCE.cbWndExtra = 0; WCE.hInstance = hinstance; WCE.hIcon = NULL;//LoadImage() WCE.hCursor = NULL;//LoadCursor(NULL, IDC_CROSS); WCE.hbrBackground = (HBRUSH) COLOR_BACKGROUND; WCE.lpszMenuName = NULL; WCE.lpszClassName = "KyleWindow"; WCE.hIconSm = NULL; RegisterClassEx(&amp;WCE); HWND WindowHandle; WindowHandle = CreateWindowEx(WS_OVERLAPPEDWINDOW, "KyleWindow", "Xerus", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, hinstance, NULL); ShowWindow(WindowHandle, SW_SHOWNORMAL); UpdateWindow(WindowHandle); std::cout&lt;&lt;"'Opened' Window"&lt;&lt;std::endl; MSG msg; while(!quit) { if(PeekMessage(&amp;msg, NULL, NULL, NULL, PM_REMOVE)) { if(msg.message == WM_QUIT) quit = true; TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } } return msg.lParam; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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