<?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[Mir fehlt die Idee für die Lösung :(]]></title><description><![CDATA[<p>Hallo.<br />
Ich versuche gerade nen kleines Würfelspiel zu programmieren.</p>
<p>Wenn man auf den Button1 (Würfeln) klickt, generiert er zwei Zufallszahlen in den beiden Editfelder.</p>
<p>Wenn man auf den Button2 (Wurf ausblenden) klickt, kommen anstatt die Zahlen zwei X X (zum ausblenden eben) in den Felder.</p>
<p>Bishier klappt alles soweit.</p>
<p>Aber ich bekomm es nicht hin:</p>
<p>Wenn man auf Button3 (Wurf wieder einblenden) klickt, soll er den ALTEN Wurf wieder anzeigen.</p>
<p>Wenn ich ganz normal wieder die Funktion oder so aufrufe, generiert er mir ja sofort neue.</p>
<p>Hier mal der Code von den drei Buttons:</p>
<pre><code class="language-cpp">void CnewgoDlg::OnBnClickedButton1() // WÜRFELN
{
		CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT1);  
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT2); 

        CString str; 

		srand( (unsigned)time( NULL ) ); // Initialisiert den Random-Generator mit der akt. Zeit in Sek
		int w1,w2;
		w1 = rand()%6+1; 
		w2 = rand()%6+1;

		str.Format(_T(&quot;%d&quot;), w1);		
		pEdit2-&gt;SetWindowText(str); 

		str.Format(_T(&quot;%d&quot;), w2);
		pEdit1-&gt;SetWindowText(str);//Das Ergebnis wird im Edit-Feld  angezeigt

}

void CnewgoDlg::OnEnChangeEdit1()
{
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}

void CnewgoDlg::OnBnClickedButton2() //WURF AUSBLENDEN
{
		CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT1);  //ID's werden übergeben?!
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT2); 
		CString str; 

		str.Format(_T(&quot;X&quot;));		
		pEdit2-&gt;SetWindowText(str);

		str.Format(_T(&quot;X&quot;));
		pEdit1-&gt;SetWindowText(str);

}

void CnewgoDlg::OnBnClickedButton3() //WIEDER EINBLENDEN
{

	// Bei dem Button soll der alte Wurf wieder angezeigt werden

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/248461/mir-fehlt-die-idee-für-die-lösung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 02:34:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/248461.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Aug 2009 10:35:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:35:44 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Ich versuche gerade nen kleines Würfelspiel zu programmieren.</p>
<p>Wenn man auf den Button1 (Würfeln) klickt, generiert er zwei Zufallszahlen in den beiden Editfelder.</p>
<p>Wenn man auf den Button2 (Wurf ausblenden) klickt, kommen anstatt die Zahlen zwei X X (zum ausblenden eben) in den Felder.</p>
<p>Bishier klappt alles soweit.</p>
<p>Aber ich bekomm es nicht hin:</p>
<p>Wenn man auf Button3 (Wurf wieder einblenden) klickt, soll er den ALTEN Wurf wieder anzeigen.</p>
<p>Wenn ich ganz normal wieder die Funktion oder so aufrufe, generiert er mir ja sofort neue.</p>
<p>Hier mal der Code von den drei Buttons:</p>
<pre><code class="language-cpp">void CnewgoDlg::OnBnClickedButton1() // WÜRFELN
{
		CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT1);  
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT2); 

        CString str; 

		srand( (unsigned)time( NULL ) ); // Initialisiert den Random-Generator mit der akt. Zeit in Sek
		int w1,w2;
		w1 = rand()%6+1; 
		w2 = rand()%6+1;

		str.Format(_T(&quot;%d&quot;), w1);		
		pEdit2-&gt;SetWindowText(str); 

		str.Format(_T(&quot;%d&quot;), w2);
		pEdit1-&gt;SetWindowText(str);//Das Ergebnis wird im Edit-Feld  angezeigt

}

void CnewgoDlg::OnEnChangeEdit1()
{
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}

void CnewgoDlg::OnBnClickedButton2() //WURF AUSBLENDEN
{
		CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT1);  //ID's werden übergeben?!
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT2); 
		CString str; 

		str.Format(_T(&quot;X&quot;));		
		pEdit2-&gt;SetWindowText(str);

		str.Format(_T(&quot;X&quot;));
		pEdit1-&gt;SetWindowText(str);

}

void CnewgoDlg::OnBnClickedButton3() //WIEDER EINBLENDEN
{

	// Bei dem Button soll der alte Wurf wieder angezeigt werden

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1766317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766317</guid><dc:creator><![CDATA[Kanios]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:35:44 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:37:29 GMT]]></title><description><![CDATA[<p>In Standard-C++ gibts keine Buttons. Sicher dass du im richtigen Forum bist? Lies dir bitte auch die mit &quot;wichtig&quot; markierten Threads hier im Forum durch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766318</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766318</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:37:29 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:50:05 GMT]]></title><description><![CDATA[<p>Ehm ja denn verschiebs mal ins MFC pls</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766332</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766332</guid><dc:creator><![CDATA[Kanios]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:50:05 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:50:51 GMT]]></title><description><![CDATA[<p>Naja ehm wobei die Lösung ja in c++ erfolgt....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766333</guid><dc:creator><![CDATA[Kanios nochmal]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:50:51 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:53:09 GMT]]></title><description><![CDATA[<p>Es gibt zufällig dieses Forum: MFC (Visual C++)<br />
Das sagt alles oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766336</guid><dc:creator><![CDATA[-insane- 0]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 11:02:49 GMT]]></title><description><![CDATA[<p>Du musst das Ergebnis von Wurf 1 in einer Variablen zwischenspeichern. Auch sollte der Zufallsgenerator nur einmal initialisiert werden und nicht vor jedem neuen Wurf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766337</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Tue, 25 Aug 2009 11:02:49 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:55:03 GMT]]></title><description><![CDATA[<p>aso jetz erst richtig verstanden, sorry. Du musst dir wohl den letzten Wurf abspeichern, z.B. als Attribute der Klasse. Dann kannst du beim Klick auf den dritten button die alten Werte wieder hervorholen (und musst sie beim Klick auf Button 1 natürlich neu setzen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766338</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:55:03 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:56:09 GMT]]></title><description><![CDATA[<p>Mach doch einfach w1 und w2 Member der Klasse (und nicht lokale Variable), dann hast du sie sowohl beim Würfeln, als auch später beim Wiederanzeigen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766340</guid><dc:creator><![CDATA[lagalopex]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:56:09 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 10:56:32 GMT]]></title><description><![CDATA[<p>Lösung: merk dir die beiden Würfelzahlen w1 und w2 in Klassenmembern (statt lokalen Variablen)</p>
<p>P.S: MFC ist grottig, such dir auf Dauer eine bessere GUI</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1766342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766342</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Tue, 25 Aug 2009 10:56:32 GMT</pubDate></item><item><title><![CDATA[Reply to Mir fehlt die Idee für die Lösung :( on Tue, 25 Aug 2009 12:06:49 GMT]]></title><description><![CDATA[<p>Mach in die Klasse z.B. zwei Membervariablen m_w1str und m_w2str vom Typ CString rein und dann:</p>
<pre><code>void CnewgoDlg::OnBnClickedButton1() // WÜRFELN
{
        CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT1);  
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT2);

        CString str;

        srand( (unsigned)time( NULL ) ); // Initialisiert den Random-Generator mit der akt. Zeit in Sek
        int w1,w2;
        w1 = rand()%6+1;
        w2 = rand()%6+1;

        m_w1str.Format(_T(&quot;%d&quot;), w1);       
        pEdit1-&gt;SetWindowText(m_w1str);

        m_w2str.Format(_T(&quot;%d&quot;), w2);
        pEdit2-&gt;SetWindowText(m_w2str);//Das Ergebnis wird im Edit-Feld  angezeigt

}

void CnewgoDlg::OnEnChangeEdit1()
{
    // TODO:  If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CDialog::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.

    // TODO:  Add your control notification handler code here
}

void CnewgoDlg::OnBnClickedButton2() //WURF AUSBLENDEN
{
        CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT1);  //ID's werden übergeben?!
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT2);

        pEdit2-&gt;SetWindowText(_T(&quot;X&quot;));
        pEdit1-&gt;SetWindowText(_T(&quot;X&quot;));

}

void CnewgoDlg::OnBnClickedButton3() //WIEDER EINBLENDEN
{
        pEdit1-&gt;SetWindowText(m_w1str);
        pEdit2-&gt;SetWindowText(m_w2str);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1766388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1766388</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Tue, 25 Aug 2009 12:06:49 GMT</pubDate></item></channel></rss>