<?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[Buttons verschwinden...]]></title><description><![CDATA[<p>Hallo!<br />
Ich bin relativ neu bei der WinAPI Programmierung. Jetzt habe ich ein kleines Problem: Solange ich bloß Buttons, Textfelder etc einbau, läuft alles reibungslos.<br />
Sobald ich einen Text einfüge und dann zwischen Fenstern wechsle, sind die Buttons und das Editfeld nicht mehr zu sehen. Das wird an WM_PAINT liegen, aber ich weis nicht, wie ich das beheben soll... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Hier ist mein Code:</p>
<pre><code>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HWND hButton;
	static HWND hEditbox;
	char		szBuffer[20];
	double		fnumber;
	double		fandereZahl=5;
	static HINSTANCE hInstance;
	int k;
	const char  szText[] = &quot;Überschrift&quot;;

	switch (message)
	{
	case WM_PAINT:
      {
         PAINTSTRUCT   ps;
         HDC           hDC;
		 hDC = BeginPaint(hwnd, &amp;ps);
         {
			TextOut(hDC, 10, 10, szText, sizeof(szText) - 1);
		 }
         EndPaint(hwnd, &amp;ps);
		 return 0;
      }

	case WM_CREATE:

		hButton = CreateWindow ( &quot;button&quot;, &quot;Button1&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
							 10, 60, 130, 40, hwnd, (HMENU)1, 
							 (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
		hButton = CreateWindow ( &quot;button&quot;, &quot;Button2&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
							 10, 100, 130, 40, hwnd, (HMENU)2, 
							 (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
		hEditbox   = CreateWindowEx (WS_EX_CLIENTEDGE, &quot;edit&quot;, &quot;&quot;, WS_CHILD | WS_VISIBLE,
							 10, 30, 130, 25, hwnd, (HMENU)10, 
							 (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
		return 0;

	case WM_COMMAND:
		return 0;	

	case WM_DESTROY:
	     PostQuitMessage (0);
		 return 0;

	}

	return DefWindowProc (hwnd, message, wParam, lParam);
}
</code></pre>
<p>BTW: wie ändert man die Schriftfarben? Ist bei mir immer Schwarz auf weiß, was bei grauem Hintergrund merkwürdig aussieht...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/183244/buttons-verschwinden</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 05:07:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/183244.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Jun 2007 09:18:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Buttons verschwinden... on Sun, 03 Jun 2007 09:18:42 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Ich bin relativ neu bei der WinAPI Programmierung. Jetzt habe ich ein kleines Problem: Solange ich bloß Buttons, Textfelder etc einbau, läuft alles reibungslos.<br />
Sobald ich einen Text einfüge und dann zwischen Fenstern wechsle, sind die Buttons und das Editfeld nicht mehr zu sehen. Das wird an WM_PAINT liegen, aber ich weis nicht, wie ich das beheben soll... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Hier ist mein Code:</p>
<pre><code>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HWND hButton;
	static HWND hEditbox;
	char		szBuffer[20];
	double		fnumber;
	double		fandereZahl=5;
	static HINSTANCE hInstance;
	int k;
	const char  szText[] = &quot;Überschrift&quot;;

	switch (message)
	{
	case WM_PAINT:
      {
         PAINTSTRUCT   ps;
         HDC           hDC;
		 hDC = BeginPaint(hwnd, &amp;ps);
         {
			TextOut(hDC, 10, 10, szText, sizeof(szText) - 1);
		 }
         EndPaint(hwnd, &amp;ps);
		 return 0;
      }

	case WM_CREATE:

		hButton = CreateWindow ( &quot;button&quot;, &quot;Button1&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
							 10, 60, 130, 40, hwnd, (HMENU)1, 
							 (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
		hButton = CreateWindow ( &quot;button&quot;, &quot;Button2&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
							 10, 100, 130, 40, hwnd, (HMENU)2, 
							 (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
		hEditbox   = CreateWindowEx (WS_EX_CLIENTEDGE, &quot;edit&quot;, &quot;&quot;, WS_CHILD | WS_VISIBLE,
							 10, 30, 130, 25, hwnd, (HMENU)10, 
							 (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
		return 0;

	case WM_COMMAND:
		return 0;	

	case WM_DESTROY:
	     PostQuitMessage (0);
		 return 0;

	}

	return DefWindowProc (hwnd, message, wParam, lParam);
}
</code></pre>
<p>BTW: wie ändert man die Schriftfarben? Ist bei mir immer Schwarz auf weiß, was bei grauem Hintergrund merkwürdig aussieht...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297581</guid><dc:creator><![CDATA[Extinction]]></dc:creator><pubDate>Sun, 03 Jun 2007 09:18:42 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Sun, 03 Jun 2007 20:33:37 GMT]]></title><description><![CDATA[<p>Zunächst solltest Du mal den Code richtig schreiben. Bei Deinen WM_CREATE und WM_COMMAND-Blöcken fehlen nämlich die geschweiften Funktionsklammern.</p>
<blockquote>
<p>Sobald ich einen Text einfüge und dann zwischen Fenstern wechsle, sind die Buttons und das Editfeld nicht mehr zu sehen</p>
</blockquote>
<p>den Text wo einfügst und zwichen welchen Fenstern wechselst? Und wozu brauchst Du bei den HINSTANCE-Parametern der Buttons GetWindowLong? Dort sollte normalerweise</p>
<pre><code>((LPCREATESTRUCT)lParam)-&gt;hInstance
</code></pre>
<p>stehen.</p>
<p>Übrigens: Diese Zeile:</p>
<pre><code>case WM_COMMAND:
        return 0;
</code></pre>
<p>ist unnötig. Wenn Du WM_COMMAND nicht bearbeiten willst, überlaß das der DefWindowProc.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297603</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Sun, 03 Jun 2007 20:33:37 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Sun, 03 Jun 2007 13:03:51 GMT]]></title><description><![CDATA[<p>Sehe ich das richtig, dass sich die Fenster überlappen?<br />
Wenn die Fenster nicht die Stile WS_CLIPSIBLINGS haben kann dies nicht funktionieren!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297720</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297720</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Sun, 03 Jun 2007 13:03:51 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Sun, 03 Jun 2007 13:29:38 GMT]]></title><description><![CDATA[<pre><code>case WM_COMMAND:
        return 0;
</code></pre>
<p>is genau wie z.B.</p>
<pre><code>int k;
</code></pre>
<p>überflüssig. Hab ein paar unwesentliche Sachen aus dem Code gestrichen. Normalerweise kommt das natürlich nicht ohne WM_COMMAND aus.</p>
<p>Warum es aber</p>
<pre><code>((LPCREATESTRUCT)lParam)-&gt;hInstance
</code></pre>
<p>und nicht</p>
<pre><code>(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE)
</code></pre>
<p>heißen muss, weis ich nicht. Blicke durch HINSTANCE nicht ganz durch.</p>
<p>WS_CLIPSIBLINGS -&gt; das hat's vollbracht <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="🙂"
    /> danke!<br />
Wie ich den Text schön formatier steht bestimmt irgendwo auch in nem tut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297736</guid><dc:creator><![CDATA[Extinction]]></dc:creator><pubDate>Sun, 03 Jun 2007 13:29:38 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Sun, 03 Jun 2007 13:41:27 GMT]]></title><description><![CDATA[<blockquote>
<p>... sind die Buttons und das Editfeld nicht mehr zu sehen. Das wird an WM_PAINT ...liegen</p>
</blockquote>
<p>So ist es.<br />
Wenn Du bei &quot;WM_PAINT&quot; nach &quot;EndPaint() &quot;return 0&quot; zurückgibst, wird nur das gezeichnet, was zwischen &quot;BeginPaint ()&quot; und &quot;EndPaint ()&quot; liegt.<br />
Die Controls werden aber gewissermassen von &quot;DefWindowProc ()&quot; gezeichnet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297747</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 03 Jun 2007 13:41:27 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Mon, 04 Jun 2007 06:07:11 GMT]]></title><description><![CDATA[<p>HINSTANCE ist das Handle auf die geladene Programm Instanz in Deinem Prozess.</p>
<p>Solche HINSTANCE Handles werden benötigt um Resourcen zu finden, Fensterklassen zuzuordnen oder einfach Prozess/Modul-Infos mit zu übergeben und zu bekommen.</p>
<p>Dein WinMain bekommt das hInstance. Speichere den Wert in einer globalen Variable.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298197</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298197</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 04 Jun 2007 06:07:11 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Mon, 04 Jun 2007 08:34:20 GMT]]></title><description><![CDATA[<p>Extinction schrieb:</p>
<blockquote>
<p>Warum es aber</p>
<pre><code>((LPCREATESTRUCT)lParam)-&gt;hInstance
</code></pre>
<p>und nicht</p>
<pre><code>(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE)
</code></pre>
<p>heißen muss, weis ich nicht. Blicke durch HINSTANCE nicht ganz durch.</p>
</blockquote>
<p>HINSTANCE (Handle to an Instance) enthält die Instanz Deines Programmes. Die gesamten Programm- und Fensterparameter werden in einer CREATESTRUCT abgespeichert, eben auch das hInstance. Wenn Du Childfenster erstellst (ein Button ist nichts anderes), mußt Du dafür die Programminstance abfragen, indem Du einen Zeiger auf das Strukturelement (lParam)hInstance in der CreateStruct setzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298228</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Mon, 04 Jun 2007 08:34:20 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Mon, 04 Jun 2007 17:40:50 GMT]]></title><description><![CDATA[<p>Es ist aber total egal, ob man aufs CREATESTRUCT zugreift, die HINSTANCE via GetModuleHandle oder GetWindowLongPtr ermittelt... es sei denn Du musst auf andere Zielmodule zugreifen. Siehe Martins Erläuterung. Das kommt manchmal vor, wenn Du Resourcen in DLL's auslagerst ( <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> Resource-Only-DLL's).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298770</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 04 Jun 2007 17:40:50 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Mon, 04 Jun 2007 18:23:21 GMT]]></title><description><![CDATA[<p>GetModuleHandle(0) funktioniert z.B. in DLLs nicht. Ich würde grundsätzlich den übergebenen HINSTANCE Wert speichern und nutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298796</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298796</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 04 Jun 2007 18:23:21 GMT</pubDate></item><item><title><![CDATA[Reply to Buttons verschwinden... on Mon, 04 Jun 2007 18:33:19 GMT]]></title><description><![CDATA[<p>Joar, wenn mehrere Module im Spiel, verwende ich sowieso globale Variablen <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="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298799</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 04 Jun 2007 18:33:19 GMT</pubDate></item></channel></rss>