<?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[Fehler schon im Grundgerüst]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich will grad ein Programm schreiben und habe das Grundgerüst erschaffen und schon da kommt ne Fehlermeldung.<br />
Ich habe den Code 1 zu 1 aus dem Buch (Petzold) abgeschrieben und aus irgendeinem Grund wird die MessageBox, ausgelöst, die nach dem Registrieren der Fensterklasse bei einem Fehler kommt. Hier der Code</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   PSTR szCmdLine, int iCmdShow)
{
	static TCHAR szAppName[]=TEXT(&quot;MessageTest&quot;);
	HWND hwnd;
	MSG msg;
	WNDCLASS wndclass;

	wndclass.style = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc = WndProc;
	wndclass.cbClsExtra = 0;
	wndclass.cbWndExtra = 0;
	wndclass.hInstance = hInstance;
	wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndclass.lpszMenuName = NULL;
	wndclass.lpszClassName = szAppName;

	if(!RegisterClass (&amp;wndclass))
	{
		MessageBox(NULL, TEXT(&quot;Fehler beim initialisieren.&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	hwnd = CreateWindow (szAppName,
						 szAppName,
						 WS_OVERLAPPEDWINDOW,
						 100, 
						 100,
						 600,
						 400,
						 NULL,
						 NULL,
						 hInstance,
						 NULL);

	ShowWindow(hwnd, iCmdShow);
	UpdateWindow(hwnd);

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

	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, 
						 WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	case WM_CREATE:

		return 0;
	case WM_PAINT:

		return 0;
	case WM_COMMAND:

		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
<p>Wo ist denn da der Fehler? Oder liegt es eher an meinem PC?</p>
<p>Grüße<br />
Max</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191241/fehler-schon-im-grundgerüst</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 13:38:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191241.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 31 Aug 2007 15:32:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler schon im Grundgerüst on Fri, 31 Aug 2007 15:32:42 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich will grad ein Programm schreiben und habe das Grundgerüst erschaffen und schon da kommt ne Fehlermeldung.<br />
Ich habe den Code 1 zu 1 aus dem Buch (Petzold) abgeschrieben und aus irgendeinem Grund wird die MessageBox, ausgelöst, die nach dem Registrieren der Fensterklasse bei einem Fehler kommt. Hier der Code</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   PSTR szCmdLine, int iCmdShow)
{
	static TCHAR szAppName[]=TEXT(&quot;MessageTest&quot;);
	HWND hwnd;
	MSG msg;
	WNDCLASS wndclass;

	wndclass.style = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc = WndProc;
	wndclass.cbClsExtra = 0;
	wndclass.cbWndExtra = 0;
	wndclass.hInstance = hInstance;
	wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndclass.lpszMenuName = NULL;
	wndclass.lpszClassName = szAppName;

	if(!RegisterClass (&amp;wndclass))
	{
		MessageBox(NULL, TEXT(&quot;Fehler beim initialisieren.&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	hwnd = CreateWindow (szAppName,
						 szAppName,
						 WS_OVERLAPPEDWINDOW,
						 100, 
						 100,
						 600,
						 400,
						 NULL,
						 NULL,
						 hInstance,
						 NULL);

	ShowWindow(hwnd, iCmdShow);
	UpdateWindow(hwnd);

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

	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, 
						 WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	case WM_CREATE:

		return 0;
	case WM_PAINT:

		return 0;
	case WM_COMMAND:

		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
<p>Wo ist denn da der Fehler? Oder liegt es eher an meinem PC?</p>
<p>Grüße<br />
Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1356217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1356217</guid><dc:creator><![CDATA[Max3000]]></dc:creator><pubDate>Fri, 31 Aug 2007 15:32:42 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler schon im Grundgerüst on Fri, 31 Aug 2007 15:54:25 GMT]]></title><description><![CDATA[<p>memset(&amp;wndclass,0,sizeof(wndclass)); mal davor machen bzw. wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1356238</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1356238</guid><dc:creator><![CDATA[CodeGrinder]]></dc:creator><pubDate>Fri, 31 Aug 2007 15:54:25 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler schon im Grundgerüst on Fri, 31 Aug 2007 15:55:10 GMT]]></title><description><![CDATA[<p>Du musst alle Elemente der Struktur 'WNDCLASS' besetzen. Die, die Du nicht explizit initialisierst, musst Du auf 0 setzen. Des weiteren solltest Du beim Element 'hbrBackground' einen Brush angeben, da Dein Fenster sonst keinen eigenen Hintergrund hat, da ist aber auch experimentieren gefragt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .<br />
So geht es:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    static TCHAR szAppName[]=TEXT(&quot;MessageTest&quot;);
    HWND hwnd;
    MSG msg;
	WNDCLASS wndclass = { 0 };

    wndclass.style = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.lpszClassName = szAppName;
	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

    if(!RegisterClass (&amp;wndclass))
    {
        MessageBox(NULL, TEXT(&quot;Fehler beim initialisieren.&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    hwnd = CreateWindow (szAppName,
                         szAppName,
                         WS_OVERLAPPEDWINDOW,
                         100,
                         100,
                         600,
                         400,
                         NULL,
                         NULL,
                         hInstance,
                         NULL);

    ShowWindow(hwnd, iCmdShow);
    UpdateWindow(hwnd);

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

    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                         WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
    case WM_CREATE:

        return 0;
    case WM_PAINT:

        return 0;
    case WM_COMMAND:

        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1356240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1356240</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Fri, 31 Aug 2007 15:55:10 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler schon im Grundgerüst on Fri, 31 Aug 2007 15:57:18 GMT]]></title><description><![CDATA[<p>CodeFinder du bist zu lahm</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1356241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1356241</guid><dc:creator><![CDATA[CodeGrinder]]></dc:creator><pubDate>Fri, 31 Aug 2007 15:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler schon im Grundgerüst on Fri, 31 Aug 2007 16:21:37 GMT]]></title><description><![CDATA[<p>Na eben.<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /><br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1356272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1356272</guid><dc:creator><![CDATA[Max3000]]></dc:creator><pubDate>Fri, 31 Aug 2007 16:21:37 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler schon im Grundgerüst on Sat, 01 Sep 2007 09:39:15 GMT]]></title><description><![CDATA[<p>CodeGrinder schrieb:</p>
<blockquote>
<p>CodeFinder du bist zu lahm</p>
</blockquote>
<p>Meine Erklärungen waren aber ausführlicher :p .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1356656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1356656</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 01 Sep 2007 09:39:15 GMT</pubDate></item></channel></rss>