<?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[selbsterstellter font, hintergrundfarbe des fonts ändern]]></title><description><![CDATA[<p>hi, ich male mir eine fläche grau an und möchte dann darauf schreiben (mit einem selbst erstellten font).</p>
<p>der hintergrund des textes den ich ausgebe ist dann aber weis, soll aber grau sein(wie der hintergrund). wie funktioniert das?</p>
<p>wie kann ich die hintergrundfarbe der schrift ändern, damit diese auch grau ist?</p>
<pre><code class="language-cpp">case WM_PAINT:
        {

        RECT clientArea;

        hdc = BeginPaint(hWnd, &amp;ps);
        HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc,
                                                CreateSolidBrush(RGB(198,192,192)));

        SelectObject(hdc, CreatePen(PS_SOLID, 0, RGB(198, 192, 192)));

        clientArea.left = 0;
        clientArea.top  = 0;
        clientArea.right = iWindowWidth;
        clientArea.bottom = iWindowHeight / 10;

        Rectangle(hdc,
                  0,
                  0,
                  iWindowWidth,
                  iWindowHeight / 10);

        DeleteObject(SelectObject(hdc, hOldBrush));

        /******************************************/

        HFONT hFont = CreateFont(16,
                                 23,
                                  0,
                                  0,
                                  FW_NORMAL,
                                  false,
                                  false,
                                  false,
                                  DEFAULT_CHARSET,
                                  OUT_DEFAULT_PRECIS,
                                  CLIP_DEFAULT_PRECIS,
                                  ANTIALIASED_QUALITY,
                                  DEFAULT_PITCH ,
                                  L&quot;test&quot;);

        SelectObject(hdc, hFont);
        TextOut(hdc, 20, 30, L&quot;hallo&quot;, 5);

        DeleteObject(hFont);

        EndPaint(hWnd, &amp;ps);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/189163/selbsterstellter-font-hintergrundfarbe-des-fonts-ändern</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 02:31:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/189163.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 09 Aug 2007 09:53:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to selbsterstellter font, hintergrundfarbe des fonts ändern on Thu, 09 Aug 2007 09:53:01 GMT]]></title><description><![CDATA[<p>hi, ich male mir eine fläche grau an und möchte dann darauf schreiben (mit einem selbst erstellten font).</p>
<p>der hintergrund des textes den ich ausgebe ist dann aber weis, soll aber grau sein(wie der hintergrund). wie funktioniert das?</p>
<p>wie kann ich die hintergrundfarbe der schrift ändern, damit diese auch grau ist?</p>
<pre><code class="language-cpp">case WM_PAINT:
        {

        RECT clientArea;

        hdc = BeginPaint(hWnd, &amp;ps);
        HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc,
                                                CreateSolidBrush(RGB(198,192,192)));

        SelectObject(hdc, CreatePen(PS_SOLID, 0, RGB(198, 192, 192)));

        clientArea.left = 0;
        clientArea.top  = 0;
        clientArea.right = iWindowWidth;
        clientArea.bottom = iWindowHeight / 10;

        Rectangle(hdc,
                  0,
                  0,
                  iWindowWidth,
                  iWindowHeight / 10);

        DeleteObject(SelectObject(hdc, hOldBrush));

        /******************************************/

        HFONT hFont = CreateFont(16,
                                 23,
                                  0,
                                  0,
                                  FW_NORMAL,
                                  false,
                                  false,
                                  false,
                                  DEFAULT_CHARSET,
                                  OUT_DEFAULT_PRECIS,
                                  CLIP_DEFAULT_PRECIS,
                                  ANTIALIASED_QUALITY,
                                  DEFAULT_PITCH ,
                                  L&quot;test&quot;);

        SelectObject(hdc, hFont);
        TextOut(hdc, 20, 30, L&quot;hallo&quot;, 5);

        DeleteObject(hFont);

        EndPaint(hWnd, &amp;ps);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1341354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341354</guid><dc:creator><![CDATA[otto231]]></dc:creator><pubDate>Thu, 09 Aug 2007 09:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to selbsterstellter font, hintergrundfarbe des fonts ändern on Thu, 09 Aug 2007 13:00:44 GMT]]></title><description><![CDATA[<p>otto231 schrieb:</p>
<blockquote>
<p>wie kann ich die hintergrundfarbe der schrift ändern, damit diese auch grau ist?</p>
</blockquote>
<p>Z.B. via SetBkColor () :</p>
<pre><code class="language-cpp">...
 SelectObject (hdc, hFont);

 SetBkColor   (hdc,RGB(198,192,192)); // ändert Hintergrundfarbe der Schrift
 SetTextColor (hdc,RGB(255,255,0));   // ändert Schriftfarbe :-)

 TextOut      (hdc, 20, 30, L&quot;hallo&quot;, 5);
 DeleteObject (hFont);
...
</code></pre>
<p><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/1341519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341519</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 09 Aug 2007 13:00:44 GMT</pubDate></item><item><title><![CDATA[Reply to selbsterstellter font, hintergrundfarbe des fonts ändern on Thu, 09 Aug 2007 13:54:57 GMT]]></title><description><![CDATA[<p>Oder SetBkMode <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/1341564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341564</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 09 Aug 2007 13:54:57 GMT</pubDate></item><item><title><![CDATA[Reply to selbsterstellter font, hintergrundfarbe des fonts ändern on Thu, 09 Aug 2007 14:40:52 GMT]]></title><description><![CDATA[<p>Hab zwar noch nie einen Font selbst erstellt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> ,<br />
aber ich denke, daß der Font selbst natürlich keine weiße Hintergrundfarbe haben darf, sondern irgendwas transparentes oder ohne Hintergrundfarbe.</p>
<p>Ansonsten würden die Vorschläge von merker und CodeFinder keine Wirkung zeigen. Ist doch einleuchtend, oder nicht <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="😉"
    /><br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1341611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341611</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Thu, 09 Aug 2007 14:40:52 GMT</pubDate></item><item><title><![CDATA[Reply to selbsterstellter font, hintergrundfarbe des fonts ändern on Thu, 09 Aug 2007 15:11:17 GMT]]></title><description><![CDATA[<p>Mmacher schrieb:</p>
<blockquote>
<p>Hab zwar noch nie einen Font selbst erstellt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> ,<br />
aber ich denke, daß der Font selbst natürlich keine weiße Hintergrundfarbe haben darf, sondern irgendwas transparentes oder ohne Hintergrundfarbe.</p>
</blockquote>
<p>Eine Schrift hat in der WinAPI immer eine Hintergrundfarbe (falls TRANSPARENT-Mode nicht gesetzt, dann ist die Farbe egal). Diese legt zum Beispiel fest wie der Inhalt des B's (also der Buchstabe 'B') gefüllt wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1341644</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341644</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 09 Aug 2007 15:11:17 GMT</pubDate></item></channel></rss>