<?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[Status für CheckBox merken]]></title><description><![CDATA[<p>Hi, nur ganz kurz. Ich habe eine DialogBox mit einer CheckBox. Funktioniert auch alles, allerdings sind gesetzte Häkchen nach nochmaligem Öffnen des Dialogs verschwunden. Wie kann ich denn den Status auch bei nochmaligem Öffnen beibehalten?</p>
<p>thnx &amp; greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196015/status-für-checkbox-merken</link><generator>RSS for Node</generator><lastBuildDate>Mon, 29 Jun 2026 18:41:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196015.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Oct 2007 14:18:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Status für CheckBox merken on Wed, 24 Oct 2007 14:18:47 GMT]]></title><description><![CDATA[<p>Hi, nur ganz kurz. Ich habe eine DialogBox mit einer CheckBox. Funktioniert auch alles, allerdings sind gesetzte Häkchen nach nochmaligem Öffnen des Dialogs verschwunden. Wie kann ich denn den Status auch bei nochmaligem Öffnen beibehalten?</p>
<p>thnx &amp; greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391277</guid><dc:creator><![CDATA[eugler]]></dc:creator><pubDate>Wed, 24 Oct 2007 14:18:47 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Wed, 24 Oct 2007 14:23:33 GMT]]></title><description><![CDATA[<p>Das mußt Du selbst bei Nachricht WM_INITDIALOG setzen!</p>
<p>z.B. so:</p>
<pre><code class="language-cpp">if ( b_einstellung_aktiv != 0 )                          //Deine Variable mit der Einstellung für CheckBox.
{
  CheckDlgButton( hwnd_dialog, IDC_CHECKBOX, BST_CHECKED );
}
</code></pre>
<p>Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391280</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391280</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Wed, 24 Oct 2007 14:23:33 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Wed, 24 Oct 2007 15:32:55 GMT]]></title><description><![CDATA[<p>Super, es klappt! Vielen Dank Martin...ich hatte genau das gemacht, wie du, allerdings hab ich als versucht beim Aufruf des Dialogs (aus dem Menu) direkt den Wert zu setzen und nicht in der WM_InitDialog... war ja aber auch klar eigentlich...</p>
<p>Noch ne Frage: Bei den Radiobuttons geht das ganze ja sicher ähnlich, oder?<br />
Hast Du eine Ahnung wie man bestimmte RadioButtons gruppieren kann?</p>
<p>greetz &amp; thnx! <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391335</guid><dc:creator><![CDATA[eugler]]></dc:creator><pubDate>Wed, 24 Oct 2007 15:32:55 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Thu, 25 Oct 2007 07:10:03 GMT]]></title><description><![CDATA[<p>Ich gehe davon aus, Du baust Dir den Dialog mit dem Resourcen-Editor von Deiner Entwicklungsumgebung zusammen (z.B. Microsoft Visual C oder Borland C++ Builder).</p>
<p>RadioButtons kannst Du ganz einfach gruppieren, indem Du sie in eine GROUPBOX legst. So ist es auch optisch hervorgehoben, welche Radiobuttens denn zusammengehören.</p>
<p>In MSDN &quot;About Dialog Boxes&quot; <a href="http://msdn2.microsoft.com/en-us/library/ms632588.aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms632588.aspx</a> sind Links zu gut beschriebenen Erklärungen zu finden (&quot;About Dialog Boxes&quot;, &quot;Dialog Box Programming Considerations&quot;, &quot;Using Dialog Boxes&quot;)</p>
<p>Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391621</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391621</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Thu, 25 Oct 2007 07:10:03 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Thu, 25 Oct 2007 11:22:18 GMT]]></title><description><![CDATA[<p>hi, leider muss ich nochmal meinen code posten, denn irgendwie läufts doch nicht ganz rund. habe jetzt 2 checkboxen und leider beeinflusst der status der ersten immer den der zweiten... <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="😞"
    /> keine ahnung warum... sicher ist das nicht gut programmiert was ich da hab, aber denke es sollte laufen.</p>
<pre><code class="language-cpp">//Checkbox States
HWND	hCb1=NULL;
bool	cb1=TRUE;
int		state1;

HWND	hCb2=NULL;
bool	cb2=TRUE;
int		state2;

//Auszug aus dem DlgProc
switch(uMsg)
	{

	case WM_INITDIALOG:
			if(cb1==TRUE)
				CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);
			else if(cb1==FALSE)
				CheckDlgButton(hWnd, IDC_CHECK1, BST_UNCHECKED);

			if(cb2==TRUE)
				CheckDlgButton(hWnd, IDC_CHECK2, BST_CHECKED);
			else if(cb2==FALSE)
				CheckDlgButton(hWnd, IDC_CHECK2, BST_UNCHECKED);

		return TRUE;

	case WM_COMMAND:
		switch(LOWORD (wParam))
		{
		case IDC_CHECK1:

		//First get handle of checkbox by casting lParam to HWND
		hCb1 = (HWND)lParam;
		state1 = SendMessage(hCb1,BM_GETCHECK,0,0);

		if(state1 == BST_CHECKED) 
		{
			//do something
			cb1=TRUE;
		}

		else if(state1 == BST_UNCHECKED)
		{
			//do something
			cb1=FALSE;
		}

		case IDC_CHECK2:

		//First get handle of checkbox by casting lParam to HWND
		hCb2 = (HWND)lParam;
		state2 = SendMessage(hCb2,BM_GETCHECK,0,0);

		if(state2 == BST_CHECKED) 
		{
			//do something
			cb2=TRUE;
		}

		else if(state2 == BST_UNCHECKED)
		{
			//do something
			cb2=FALSE;
		}
		break;
</code></pre>
<p>Hat jemand eine vielleicht andere/geschicktere Lösung um sich die states zu merken, bzw eine idee, warum wenn der erste state angewählt wird, der zweite automatisch auch an ist?</p>
<p>thnx &amp; greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391775</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391775</guid><dc:creator><![CDATA[eugler]]></dc:creator><pubDate>Thu, 25 Oct 2007 11:22:18 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Thu, 25 Oct 2007 12:09:37 GMT]]></title><description><![CDATA[<p>Ganz klar, da fehlt ein <strong>break</strong>!</p>
<blockquote>
<p>case WM_COMMAND:<br />
switch(LOWORD (wParam))<br />
{<br />
case IDC_CHECK1:<br />
//First get handle of checkbox by casting lParam to HWND<br />
hCb1 = (HWND)lParam;<br />
state1 = SendMessage(hCb1,BM_GETCHECK,0,0);</p>
<p>if(state1 == BST_CHECKED)<br />
{<br />
//do something<br />
cb1=TRUE;<br />
}</p>
<p>else if(state1 == BST_UNCHECKED)<br />
{<br />
//do something<br />
cb1=FALSE;<br />
}<br />
<strong>break;</strong> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
<p>case IDC_CHECK2:<br />
//First get handle of checkbox by casting lParam to HWND<br />
hCb2 = (HWND)lParam;<br />
state2 = SendMessage(hCb2,BM_GETCHECK,0,0);</p>
<p>if(state2 == BST_CHECKED)<br />
{<br />
//do something<br />
cb2=TRUE;<br />
}<br />
else if(state2 == BST_UNCHECKED)<br />
{<br />
//do something<br />
cb2=FALSE;<br />
}<br />
break;</p>
</blockquote>
<p>HTH!<br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391812</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Thu, 25 Oct 2007 12:09:37 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Thu, 25 Oct 2007 12:16:29 GMT]]></title><description><![CDATA[<p>Unabhängig vom eigentlichen Problem mit dem fehlenden break; könntest Du Deine if-Abfragen ein wenig eleganter lösen.</p>
<p>Du machst für das ein und dasselbe Problem zwei gegenteilige if-Abfragen, z.B.:</p>
<p>eugler schrieb:</p>
<blockquote>
<p>if(cb1==TRUE)<br />
CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);<br />
else if(cb1==FALSE)<br />
CheckDlgButton(hWnd, IDC_CHECK1, BST_UNCHECKED);</p>
</blockquote>
<p>Ich würde eher so schreiben (eine einzige if-Abfrage genügt):</p>
<pre><code class="language-cpp">if (cb1==TRUE)
{
  CheckDlgButton(hWnd, IDC_CHECK1, BST_CHECKED);
}
else
{
  CheckDlgButton(hWnd, IDC_CHECK1, BST_UNCHECKED);
}
</code></pre>
<p>Ich persönlich setze jede noch so kleine Anweisung in Verzweigungen (if-Abfragen, do-/while-/for-Schleifen usw.) in geschweifte Klammern { und } ein. Das hilft Dir bei Fehlersuche ungemein!</p>
<p>Just my 5 Cents<br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391820</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Thu, 25 Oct 2007 12:16:29 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Thu, 25 Oct 2007 12:41:58 GMT]]></title><description><![CDATA[<p>jawohl... ganz klar das break... vielen dank! das mit den if-anweisungen werde ich auch versuchen mir zu herzen zu nehmen <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="🙂"
    /></p>
<p>greetz &amp; thnx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391846</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391846</guid><dc:creator><![CDATA[eugler]]></dc:creator><pubDate>Thu, 25 Oct 2007 12:41:58 GMT</pubDate></item><item><title><![CDATA[Reply to Status für CheckBox merken on Fri, 26 Oct 2007 16:19:46 GMT]]></title><description><![CDATA[<p>Martin, dir ist wohl entgangen das wir Kaffee süchtigen Programmierer faul sind, oder wozu wurden eben die Abkürzungen (Einzeiler ohne {}, +=, *= &amp;&amp; statt AND, etc.) eingeführt <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/1392660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392660</guid><dc:creator><![CDATA[orrlol]]></dc:creator><pubDate>Fri, 26 Oct 2007 16:19:46 GMT</pubDate></item></channel></rss>