<?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[Richedit Text adden bunt]]></title><description><![CDATA[<p>Hallo.<br />
Ich nutze ein Richedit und möchte dort text hinzufügen.<br />
Ich hab in diesem Forum dazu schon etwas gefunden gehabt aber bekomme da beim adden fehler mit der farben.</p>
<pre><code>void utilAppendTextToWindow(HWND hWnd, char *szText, COLORREF crTextColor) 
{ 
    // private 
    int tl; 
    CHARFORMAT cf; 

    tl = GetWindowTextLength(hWnd); 

    // add new text 
    SendMessage(hWnd, EM_SETSEL, tl, tl);    //letzte stelle wird markiert 
    SendMessage(hWnd, EM_REPLACESEL, FALSE, (LPARAM)szText); //text wird an die markierte stelle gehängt 

    // fill struct 
    memset( &amp;cf, 0, sizeof(CHARFORMAT) ); 

    cf.cbSize = sizeof(CHARFORMAT); 
    cf.dwMask = CFM_COLOR; 
    cf.crTextColor = crTextColor; 

    // select last text inserted 
    tl = GetWindowTextLength(hWnd); 
    SendMessage(hWnd, EM_SETSEL, (WPARAM)(tl-strlen(szText)), (LPARAM)tl); 

    // set color 
    SendMessage(hWnd, EM_SETCHARFORMAT ,SCF_SELECTION, (LPARAM)&amp;cf); 

    // remove bracket    entfernt die markierung 
    tl = GetWindowTextLength(hWnd); 
    SendMessage(hWnd, EM_SETSEL, tl, tl); 

    // set cusor to end of text 
    for(int l=0; l&lt;SendMessage(hWnd, EM_GETLINECOUNT, 0, 0); l++) 
        SendMessage(hWnd, EM_SCROLL, SB_LINEDOWN, 0); 

}
</code></pre>
<p>Wenn ich einfach immer hintenran hänge, funktioniert es, befindet sich aber ein \n hintendran und der neue text kommt in eine neue zeile, gibt es fehler mit den farben. dann hat ein teil der zeile drüber die aktuelle farbe und so weiter. ich hatte die funktion auch abgeändert und nen \n drangehängt aber der fehler war exakt der gleiche. gibts keine andere möglichkeit in eine neue zeile zu adden oder den cursor in eine neue zeile zu setzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/66234/richedit-text-adden-bunt</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 04:34:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/66234.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Feb 2004 11:54:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Richedit Text adden bunt on Thu, 26 Feb 2004 11:54:22 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Ich nutze ein Richedit und möchte dort text hinzufügen.<br />
Ich hab in diesem Forum dazu schon etwas gefunden gehabt aber bekomme da beim adden fehler mit der farben.</p>
<pre><code>void utilAppendTextToWindow(HWND hWnd, char *szText, COLORREF crTextColor) 
{ 
    // private 
    int tl; 
    CHARFORMAT cf; 

    tl = GetWindowTextLength(hWnd); 

    // add new text 
    SendMessage(hWnd, EM_SETSEL, tl, tl);    //letzte stelle wird markiert 
    SendMessage(hWnd, EM_REPLACESEL, FALSE, (LPARAM)szText); //text wird an die markierte stelle gehängt 

    // fill struct 
    memset( &amp;cf, 0, sizeof(CHARFORMAT) ); 

    cf.cbSize = sizeof(CHARFORMAT); 
    cf.dwMask = CFM_COLOR; 
    cf.crTextColor = crTextColor; 

    // select last text inserted 
    tl = GetWindowTextLength(hWnd); 
    SendMessage(hWnd, EM_SETSEL, (WPARAM)(tl-strlen(szText)), (LPARAM)tl); 

    // set color 
    SendMessage(hWnd, EM_SETCHARFORMAT ,SCF_SELECTION, (LPARAM)&amp;cf); 

    // remove bracket    entfernt die markierung 
    tl = GetWindowTextLength(hWnd); 
    SendMessage(hWnd, EM_SETSEL, tl, tl); 

    // set cusor to end of text 
    for(int l=0; l&lt;SendMessage(hWnd, EM_GETLINECOUNT, 0, 0); l++) 
        SendMessage(hWnd, EM_SCROLL, SB_LINEDOWN, 0); 

}
</code></pre>
<p>Wenn ich einfach immer hintenran hänge, funktioniert es, befindet sich aber ein \n hintendran und der neue text kommt in eine neue zeile, gibt es fehler mit den farben. dann hat ein teil der zeile drüber die aktuelle farbe und so weiter. ich hatte die funktion auch abgeändert und nen \n drangehängt aber der fehler war exakt der gleiche. gibts keine andere möglichkeit in eine neue zeile zu adden oder den cursor in eine neue zeile zu setzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/468260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/468260</guid><dc:creator><![CDATA[GrinderFX]]></dc:creator><pubDate>Thu, 26 Feb 2004 11:54:22 GMT</pubDate></item><item><title><![CDATA[Reply to Richedit Text adden bunt on Thu, 26 Feb 2004 12:03:15 GMT]]></title><description><![CDATA[<p>Hast du es mal mit \r\n versucht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/468264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/468264</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Thu, 26 Feb 2004 12:03:15 GMT</pubDate></item><item><title><![CDATA[Reply to Richedit Text adden bunt on Thu, 26 Feb 2004 13:07:33 GMT]]></title><description><![CDATA[<p>Ganz klar wieso die Farben nicht stimmen. Da kommt die Länge durcheinander... }\n oder \r\n ist der Übeltäter... Entweder zählt GetWindowTextLength zuviel, oder zu wenig.</p>
<p>Gruß,<br />
Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/post/468334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/468334</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Thu, 26 Feb 2004 13:07:33 GMT</pubDate></item><item><title><![CDATA[Reply to Richedit Text adden bunt on Fri, 27 Feb 2004 21:40:14 GMT]]></title><description><![CDATA[<p>Danke, das mit der Länge stimmt. Habs lösen können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/469313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/469313</guid><dc:creator><![CDATA[GrinderFX]]></dc:creator><pubDate>Fri, 27 Feb 2004 21:40:14 GMT</pubDate></item><item><title><![CDATA[Reply to Richedit Text adden bunt on Fri, 27 Feb 2004 22:15:21 GMT]]></title><description><![CDATA[<p>Jap so ist's halt...<br />
Gut ist, wenn jemand schonmal das Prob hatte <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 />
Muss mal nen Beispiel für 'ne Addfunktion uppen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/469328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/469328</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Fri, 27 Feb 2004 22:15:21 GMT</pubDate></item><item><title><![CDATA[Reply to Richedit Text adden bunt on Sat, 04 Jun 2005 15:12:22 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Mal nur so ne Frage :<br />
Wie hast du das denn gelöst ?</p>
<p>Gruß Linus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/802191</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/802191</guid><dc:creator><![CDATA[linus]]></dc:creator><pubDate>Sat, 04 Jun 2005 15:12:22 GMT</pubDate></item></channel></rss>