<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CreateWindow liefert keinen HANDLE zurück]]></title><description><![CDATA[<p>Moin,</p>
<p>ich schreibe manchmal WinApi-Programme, die dann einfach nicht angezeigt werden - obwohl ich keine Variation drinhabe.</p>
<p>Mit dem Einbau von 1, 2 Fehlerabfragen bin ich dann zu dem Schluss gekommen, das bei</p>
<pre><code class="language-cpp">hWnd = CreateWindow([]);
</code></pre>
<p>nix geliefert wird.</p>
<p>Meine Frage: WARUM?</p>
<p>Ich gebe euch mal ein bissel Code und hoffe dann auf eure Antwort.</p>
<pre><code class="language-cpp">int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	HWND hWnd;
	MSG msg;
	WNDCLASS wc = {0};

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.hInstance = hInstance;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = szAppName;

	RegisterClass(&amp;wc);

	hWnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

	if(!hWnd)
	{
		MessageBox(NULL, &quot;Kein Handle&quot;, &quot;Fehler&quot;, MB_ICONERROR | MB_OK);
		exit(-1);
	}

	ShowWindow(hWnd, iCmdShow);
	UpdateWindow(hWnd);

	while(GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}

	return msg.wParam;
}
</code></pre>
<p>Euer ItsNotYou</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/92643/createwindow-liefert-keinen-handle-zurück</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 01:15:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/92643.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Nov 2004 17:32:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CreateWindow liefert keinen HANDLE zurück on Sun, 21 Nov 2004 17:32:32 GMT]]></title><description><![CDATA[<p>Moin,</p>
<p>ich schreibe manchmal WinApi-Programme, die dann einfach nicht angezeigt werden - obwohl ich keine Variation drinhabe.</p>
<p>Mit dem Einbau von 1, 2 Fehlerabfragen bin ich dann zu dem Schluss gekommen, das bei</p>
<pre><code class="language-cpp">hWnd = CreateWindow([]);
</code></pre>
<p>nix geliefert wird.</p>
<p>Meine Frage: WARUM?</p>
<p>Ich gebe euch mal ein bissel Code und hoffe dann auf eure Antwort.</p>
<pre><code class="language-cpp">int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	HWND hWnd;
	MSG msg;
	WNDCLASS wc = {0};

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.hInstance = hInstance;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = szAppName;

	RegisterClass(&amp;wc);

	hWnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

	if(!hWnd)
	{
		MessageBox(NULL, &quot;Kein Handle&quot;, &quot;Fehler&quot;, MB_ICONERROR | MB_OK);
		exit(-1);
	}

	ShowWindow(hWnd, iCmdShow);
	UpdateWindow(hWnd);

	while(GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}

	return msg.wParam;
}
</code></pre>
<p>Euer ItsNotYou</p>
]]></description><link>https://www.c-plusplus.net/forum/post/656190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/656190</guid><dc:creator><![CDATA[ItsNotYou]]></dc:creator><pubDate>Sun, 21 Nov 2004 17:32:32 GMT</pubDate></item><item><title><![CDATA[Reply to CreateWindow liefert keinen HANDLE zurück on Sun, 21 Nov 2004 17:34:03 GMT]]></title><description><![CDATA[<p>Window Procedure fehlt irgendwie <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/656193</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/656193</guid><dc:creator><![CDATA[hääää??????]]></dc:creator><pubDate>Sun, 21 Nov 2004 17:34:03 GMT</pubDate></item><item><title><![CDATA[Reply to CreateWindow liefert keinen HANDLE zurück on Sun, 21 Nov 2004 17:40:24 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HWND hEingabe;
	static HWND hIP_Berechnen;

	switch(message)
	{
	case WM_CREATE:
		{
			hEingabe = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;edit&quot;, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, NULL, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			hIP_Berechnen = CreateWindow(&quot;button&quot;, &quot;IP berechnen&quot;, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, NULL, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			return(0);
		}
	case WM_SIZE:
		{
			MoveWindow(hEingabe, 110, 50, 500, 25, TRUE);
			MoveWindow(hIP_Berechnen, 50, 50, 100, 25, TRUE);
			return(0);
		}
	case WM_COMMAND:
		{
			if(lParam == (LPARAM)hIP_Berechnen)
			{
				if(HIWORD(wParam) == BN_CLICKED)
				{
					int iLength = GetWindowTextLength(hEingabe);
					char *buffer = (CHAR*)malloc(iLength);

					GetWindowText(hEingabe, buffer, iLength + 1);

					char IP[16];
					if(IP_auslesen(IP, buffer))
					{
						hEingabe = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;edit&quot;, IP, WS_CHILD | WS_VISIBLE, 110, 50, 500, 25, hWnd, NULL, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
					}
					else
					{
						hEingabe = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;edit&quot;, &quot;Fehler beim Umrechnen&quot;, WS_CHILD | WS_VISIBLE, 110, 50, 500, 25, hWnd, NULL, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
					}

				}
			}

			return(0);
		}
	case WM_DESTROY:
		{
			PostQuitMessage(0);
			return(0);
		}
	}

	return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>Die Funktio gibts auch, ist aber aus Testgründen noch ein ei´nfaches return(TRUE).</p>
<p>Und natürlich vorher deklariert.</p>
<p>Keine Fehlermeldungen vom Compiler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/656198</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/656198</guid><dc:creator><![CDATA[ItsNotYou]]></dc:creator><pubDate>Sun, 21 Nov 2004 17:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to CreateWindow liefert keinen HANDLE zurück on Sun, 21 Nov 2004 18:07:08 GMT]]></title><description><![CDATA[<p>Die Window Procedure musst du bei der Registrierung der Klasse festlegen. Dann klappt das Programm auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/656210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/656210</guid><dc:creator><![CDATA[hä????]]></dc:creator><pubDate>Sun, 21 Nov 2004 18:07:08 GMT</pubDate></item></channel></rss>