<?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[SelectObject - Object wieder DEselectieren]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich werfe mit folgenden Code nen neuen Font in ein DC:</p>
<pre><code class="language-cpp">HGDIOBJ DDBS_Obj = SelectObject(DDBS_DC,CreateFont(38,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Comic Sans MS&quot;));
</code></pre>
<p>Schön und Gut, mein Font ist da, aber das wird 25 mal pro Sekunde gemacht,<br />
in einem Spiel mit DirectDraw (DDraw), das DC ist von einem BackSurface.</p>
<p>Wie kann ich dieses Objekt jetzt wieder freigeben??</p>
<p>DeleteObject() kann ich nicht nehmen, da sonst mein Surface zerstört wird,<br />
ich muß also &quot;Deselectieren&quot;, nur wie?</p>
<p>guß Micha</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/86011/selectobject-object-wieder-deselectieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 07:46:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/86011.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Sep 2004 19:39:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SelectObject - Object wieder DEselectieren on Tue, 14 Sep 2004 19:39:59 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich werfe mit folgenden Code nen neuen Font in ein DC:</p>
<pre><code class="language-cpp">HGDIOBJ DDBS_Obj = SelectObject(DDBS_DC,CreateFont(38,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Comic Sans MS&quot;));
</code></pre>
<p>Schön und Gut, mein Font ist da, aber das wird 25 mal pro Sekunde gemacht,<br />
in einem Spiel mit DirectDraw (DDraw), das DC ist von einem BackSurface.</p>
<p>Wie kann ich dieses Objekt jetzt wieder freigeben??</p>
<p>DeleteObject() kann ich nicht nehmen, da sonst mein Surface zerstört wird,<br />
ich muß also &quot;Deselectieren&quot;, nur wie?</p>
<p>guß Micha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607327</guid><dc:creator><![CDATA[MiC++ha]]></dc:creator><pubDate>Tue, 14 Sep 2004 19:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to SelectObject - Object wieder DEselectieren on Tue, 14 Sep 2004 19:50:36 GMT]]></title><description><![CDATA[<p>So ungefähr...</p>
<pre><code class="language-cpp">HFONT hFont = CreateFont(38,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Comic Sans MS&quot;);
HGDIOBJ hOriginalFont = SelectObject(DDBS_DC, hFont);
// Zeichnen.
SelectObject(DDBS_DC, hOriginalFont);
DeleteObject(hFont);
</code></pre>
<p>Ich würde den Font einmal am Anfang des Programms erstellen und am Ende löschen. Aber irgendwann brauchst du DeleteObject.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607331</guid><dc:creator><![CDATA[....]]></dc:creator><pubDate>Tue, 14 Sep 2004 19:50:36 GMT</pubDate></item><item><title><![CDATA[Reply to SelectObject - Object wieder DEselectieren on Tue, 14 Sep 2004 20:38:15 GMT]]></title><description><![CDATA[<p>Ja genau so, Danke.</p>
<p>Ich Hirnie hatte das auch so Vorgesehen und habe<br />
am Anfang ein paar Font Objecte erstellt, aber im<br />
ganzen drum herum und gedanken woanders und nur mal<br />
die Textaugabe meine Klasse testen etc. ist mir das<br />
entfallen. Daher habe ich da den ganz schnellen Weg<br />
gewählt, na ja jetzt habe ich es so wie es geplant<br />
war und es geht.</p>
<p>Tip: Immer bei der Planung und/oder Pflichtenheft bleiben<br />
dann klappt es auch <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>
<pre><code class="language-cpp">//Fonts setzten für Spiel
HFONT TitleScrollerFont = CreateFont(32,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Comic Sans MS&quot;);
if (TitleScrollerFont = NULL) TitleScrollerFont = CreateFont(38,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Arial&quot;);
HFONT ScoreFont = CreateFont(24,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Verdana&quot;);
if (TitleScrollerFont = NULL) ScoreFont = CreateFont(22,0,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,&quot;Arial&quot;);
//...etc...

//Aufräumen
DeleteObject(TitleScrollerFont);
DeleteObject(ScoreFont);
//....etc.....
</code></pre>
<p>Code der Routine in der Klasse</p>
<pre><code class="language-cpp">void Game::TextBlt(int X, int Y,HFONT FontType, COLORREF txtColor, char *Text)
{
    HDC DDBS_DC;
    if (DDBackSurface-&gt;GetDC(&amp;DDBS_DC) == DD_OK) {
        HGDIOBJ OldObject = SelectObject(DDBS_DC,FontType);
        SetBkMode(DDBS_DC,TRANSPARENT);
        SetTextColor(DDBS_DC,txtColor);
        TextOut(DDBS_DC, X, Y, Text, strlen(Text));
        DDBackSurface-&gt;ReleaseDC(DDBS_DC);
        SelectObject(DDBS_DC, OldObject);
        DeleteObject(FontType);
    } 
}
</code></pre>
<p>Habe mal stück Code zugesetzt, falls ich wieder mal vergesse <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/607368</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607368</guid><dc:creator><![CDATA[MiC++ha]]></dc:creator><pubDate>Tue, 14 Sep 2004 20:38:15 GMT</pubDate></item><item><title><![CDATA[Reply to SelectObject - Object wieder DEselectieren on Tue, 14 Sep 2004 20:41:32 GMT]]></title><description><![CDATA[<p>Erstellst du den Font vor jedem TextBlt neu? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>Oder warum hast du das DeleteObject in TextBlt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607370</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607370</guid><dc:creator><![CDATA[Pflichtenheftchen]]></dc:creator><pubDate>Tue, 14 Sep 2004 20:41:32 GMT</pubDate></item><item><title><![CDATA[Reply to SelectObject - Object wieder DEselectieren on Tue, 14 Sep 2004 20:58:03 GMT]]></title><description><![CDATA[<p>Upps, ne natürlich nicht.</p>
<p>Ich hatte das aus einem vorheringem Test drinn gelassen. :p</p>
<p>Hier nochmal ohne, denn sonst gehts ja nicht und der Standard Font kommt <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>
<pre><code class="language-cpp">void Game::TextBlt(int X, int Y,HFONT FontType, COLORREF txtColor, char *Text)
{
    HDC DDBS_DC;
    if (DDBackSurface-&gt;GetDC(&amp;DDBS_DC) == DD_OK) {
        HGDIOBJ OldObject = SelectObject(DDBS_DC,FontType);
        SetBkMode(DDBS_DC,TRANSPARENT);
        SetTextColor(DDBS_DC,txtColor);
        TextOut(DDBS_DC, X, Y, Text, strlen(Text));
        DDBackSurface-&gt;ReleaseDC(DDBS_DC);
        SelectObject(DDBS_DC, OldObject);
    } 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/607387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607387</guid><dc:creator><![CDATA[MiC++ha]]></dc:creator><pubDate>Tue, 14 Sep 2004 20:58:03 GMT</pubDate></item></channel></rss>