<?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[Textfarbe in Editfeld]]></title><description><![CDATA[<p>Hallo,</p>
<p>habe ein Problem das ich einfach nicht alleine gelöst bekomme.<br />
In einem Dialog habe ich ein Edit Feld und darin wird geprüft ob der eingegebene Text gleich wie ein vorgegebener ist. Abhängig davon soll die Textfarbe angepasst werden. Allerdings wird nie der gesamte Text andersfarbig gemalt, sondern nur die neu eingegebenen Zeichen, da der restliche Text nicht neu gezeichnet wird.<br />
Nun weiß ich nicht welche Message ich an das Editfeld (Dialog) schicken müsste, damit der gesamte Text mit der neuen Textfarbe gezeichnet wird. Weder ein UpdateWindow oder ein WM_PAINT helfen??? Der Text wird neugezeichnet, wenn man in ein anderes Editfeld im Dialog klickt, allerdings konnte ich nicht herausfinden welche Messages dabei gesendet werden.</p>
<pre><code class="language-cpp">static bool bValid = false;

case WM_CTLCOLOREDIT:
{
    if (GetDlgItem (hDlgUserInfo, EDIT) == (HWND)lParam)
    {
        if (!bValid)
            SetTextColor ((HDC) wParam, RGB (255,0,0));
        else
            SetTextColor ((HDC) wParam, RGB (0,255,0));

        return (BOOL) GetStockObject (WHITE_BRUSH);
    }
    else
        return FALSE;
}
break;

case WM_COMMAND:
{
    if (HIWORD (wParam) == EN_UPDATE)	
    {
        // Überprüfung
        if (same)
            bValid = true;
        else
            bValid = false;
    }
    break;
}
break;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/191440/textfarbe-in-editfeld</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 09:48:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191440.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Sep 2007 10:39:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 10:39:58 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>habe ein Problem das ich einfach nicht alleine gelöst bekomme.<br />
In einem Dialog habe ich ein Edit Feld und darin wird geprüft ob der eingegebene Text gleich wie ein vorgegebener ist. Abhängig davon soll die Textfarbe angepasst werden. Allerdings wird nie der gesamte Text andersfarbig gemalt, sondern nur die neu eingegebenen Zeichen, da der restliche Text nicht neu gezeichnet wird.<br />
Nun weiß ich nicht welche Message ich an das Editfeld (Dialog) schicken müsste, damit der gesamte Text mit der neuen Textfarbe gezeichnet wird. Weder ein UpdateWindow oder ein WM_PAINT helfen??? Der Text wird neugezeichnet, wenn man in ein anderes Editfeld im Dialog klickt, allerdings konnte ich nicht herausfinden welche Messages dabei gesendet werden.</p>
<pre><code class="language-cpp">static bool bValid = false;

case WM_CTLCOLOREDIT:
{
    if (GetDlgItem (hDlgUserInfo, EDIT) == (HWND)lParam)
    {
        if (!bValid)
            SetTextColor ((HDC) wParam, RGB (255,0,0));
        else
            SetTextColor ((HDC) wParam, RGB (0,255,0));

        return (BOOL) GetStockObject (WHITE_BRUSH);
    }
    else
        return FALSE;
}
break;

case WM_COMMAND:
{
    if (HIWORD (wParam) == EN_UPDATE)	
    {
        // Überprüfung
        if (same)
            bValid = true;
        else
            bValid = false;
    }
    break;
}
break;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1357745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357745</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Mon, 03 Sep 2007 10:39:58 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 10:49:36 GMT]]></title><description><![CDATA[<p>das funzt so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357754</guid><dc:creator><![CDATA[teppichmensch]]></dc:creator><pubDate>Mon, 03 Sep 2007 10:49:36 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 11:00:09 GMT]]></title><description><![CDATA[<p>Wenn das Edit Control read only ist, dann wird WM_CTLCOLORSTATIC gesendet!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357770</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 03 Sep 2007 11:00:09 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 11:04:43 GMT]]></title><description><![CDATA[<p>Hmm ich habe wohl nicht verständlich machen können um was es mir geht.<br />
Das Edit Control ist nicht read-only und ich empfange auch ein WM_CTLCOLOREDIT.<br />
Ebenfalls wird der Text auch schon eingefärbt. Das geht auch schon.</p>
<p>Ein Beispiel: Wenn der zu überprüfende Text &quot;Hallo&quot; sein sollte, sind die eingegebenen Buchstaben bis &quot;Hall&quot; rot, ist ja auch richtig. Wenn man dann das &quot;o&quot; eintippt, ist dieses grün, prinzipiell auch richtig, aber jetzt sollte &quot;Hallo&quot; komplett grün werden! Das bekomme ich nicht hin...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357775</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357775</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Mon, 03 Sep 2007 11:04:43 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 11:27:21 GMT]]></title><description><![CDATA[<p>das geht so. ich habs doch vorhin aus langeweile selber ausprobiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357784</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357784</guid><dc:creator><![CDATA[teppichmensch]]></dc:creator><pubDate>Mon, 03 Sep 2007 11:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 11:44:06 GMT]]></title><description><![CDATA[<p>yogle schrieb:</p>
<blockquote>
<p>Ein Beispiel: Wenn der zu überprüfende Text &quot;Hallo&quot; sein sollte, sind die eingegebenen Buchstaben bis &quot;Hall&quot; rot, ist ja auch richtig. Wenn man dann das &quot;o&quot; eintippt, ist dieses grün, prinzipiell auch richtig, aber jetzt sollte &quot;Hallo&quot; komplett grün werden! Das bekomme ich nicht hin...</p>
</blockquote>
<p>Dann muss Du ein InvalidateRect auf das ganze Control loslassen. Das Edit Control zeichnet bei der Eingabenur die Änderungen neu. Nicht den gesamten Text.<br />
In Deinem Fall wird also das o eingegeben aber auch nur dieses Zeichen neu in grün gezeichnet. &quot;Hall&quot; bleibt unverändert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357798</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 03 Sep 2007 11:44:06 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 11:47:23 GMT]]></title><description><![CDATA[<p>Ne stimmt ja nicht MArtin. Ich habs doch selbst ausprobiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357800</guid><dc:creator><![CDATA[teppichmensch]]></dc:creator><pubDate>Mon, 03 Sep 2007 11:47:23 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 12:09:49 GMT]]></title><description><![CDATA[<p>Doch mit InvalidateRect funktionierts nun. Danke Martin!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357830</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Mon, 03 Sep 2007 12:09:49 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 13:05:08 GMT]]></title><description><![CDATA[<p>yogle schrieb:</p>
<blockquote>
<p>Doch mit InvalidateRect funktionierts nun. Danke Martin!</p>
</blockquote>
<p>funktioniert auch ohne, es ist unnötig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357891</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357891</guid><dc:creator><![CDATA[teppichmensch]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:05:08 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 13:25:43 GMT]]></title><description><![CDATA[<p>Na dann zeig doch mal deinen kompletten funktionierenden Code!<br />
Also in meinem Fall ging es ohne InvalidateRect absolut nicht!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357922</guid><dc:creator><![CDATA[yogle|work]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:25:43 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 14:30:09 GMT]]></title><description><![CDATA[<p>Es ist wie ich geschrieben habe: Das Edit Control zeigt nicht bei jeder Tastatureingabe das komplette Feld neu an! Wenn die gesamte Färbung sich ändert durch die Eingabe eines Buchstabens, muss man ein InvalidateRect durchführen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357991</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 03 Sep 2007 14:30:09 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 16:30:27 GMT]]></title><description><![CDATA[<p>nein das stimmt ned, ich habs doch ausprobiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1358110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1358110</guid><dc:creator><![CDATA[teppichmensch]]></dc:creator><pubDate>Mon, 03 Sep 2007 16:30:27 GMT</pubDate></item><item><title><![CDATA[Reply to Textfarbe in Editfeld on Mon, 03 Sep 2007 16:33:13 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">BOOL CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
	static BOOL bColorRed = TRUE;

	switch(uMsg) {
		case WM_CTLCOLOREDIT:
			if(GetDlgCtrlID((HWND)lParam) == IDC_EDIT1) {
				if(bColorRed)
					SetTextColor((HDC)wParam, RGB(255,0,0));
				else
					SetTextColor((HDC)wParam, RGB(0,255,0));
				return (BOOL)GetStockObject(WHITE_BRUSH);
			}
			return FALSE;

		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDCANCEL:
					EndDialog(hDlg, HIWORD(wParam));
					return TRUE;

				case IDC_EDIT1:
					if(HIWORD(wParam) == EN_UPDATE) {
						TCHAR szBuf[128];
						GetWindowText(GetDlgItem(hDlg, IDC_EDIT1), szBuf, sizeof(szBuf));
						if(_tcsstr(szBuf, _T(&quot;test&quot;))) {
							bColorRed = FALSE;
						}	
					}
					return TRUE;
			}
			break;
	}
	return FALSE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1358114</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1358114</guid><dc:creator><![CDATA[teppichmensch]]></dc:creator><pubDate>Mon, 03 Sep 2007 16:33:13 GMT</pubDate></item></channel></rss>