<?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[CreateSolidBrush liefert NULL]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>habe eine Dialoganwendung und manchmal (eher ziemlich oft) habe ich das Problem, dass das Dialogfenster nicht richtig gezeichnet wird.</p>
<p>Wenn ich debugge sehe ich, dass</p>
<pre><code class="language-cpp">CreateSolidBrush(RGB(0,0,0));
</code></pre>
<p>NULL zurück liefert und somit kein gültiger Pinsel zum Zeichnen da ist.</p>
<p>Jetzt die Frage:</p>
<p>Wann liefert CreateSolidBrush NULL zurück?</p>
<p>Wenn ich mit GetLastError() den letzten Fehler hole, dann bekomme ich immer &quot;Der Vorgang wurde erfolgreich abgeschlossen&quot;.</p>
<p>Hat jemand eine Idee?</p>
<p>Danke und Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/200624/createsolidbrush-liefert-null</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 01:15:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/200624.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Dec 2007 16:05:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CreateSolidBrush liefert NULL on Mon, 17 Dec 2007 16:05:09 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>habe eine Dialoganwendung und manchmal (eher ziemlich oft) habe ich das Problem, dass das Dialogfenster nicht richtig gezeichnet wird.</p>
<p>Wenn ich debugge sehe ich, dass</p>
<pre><code class="language-cpp">CreateSolidBrush(RGB(0,0,0));
</code></pre>
<p>NULL zurück liefert und somit kein gültiger Pinsel zum Zeichnen da ist.</p>
<p>Jetzt die Frage:</p>
<p>Wann liefert CreateSolidBrush NULL zurück?</p>
<p>Wenn ich mit GetLastError() den letzten Fehler hole, dann bekomme ich immer &quot;Der Vorgang wurde erfolgreich abgeschlossen&quot;.</p>
<p>Hat jemand eine Idee?</p>
<p>Danke und Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422102</guid><dc:creator><![CDATA[Horst2]]></dc:creator><pubDate>Mon, 17 Dec 2007 16:05:09 GMT</pubDate></item><item><title><![CDATA[Reply to CreateSolidBrush liefert NULL on Mon, 17 Dec 2007 20:06:57 GMT]]></title><description><![CDATA[<p>CreateSolidBrush liefert NULL wenn keine Ressourcen mehr vorhanden sind.<br />
Das dauert aber ziemlich lange.<br />
Bist Du sicher das NULL returniert wird.</p>
<p>Zeige mal etwas mehr von Deinem Code.<br />
Kann es sein, dass Du in Deinem OnDraw Code den Brush erzeugst und nicht wieder deselektierst bevor Du ihn zerstörst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422267</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422267</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 17 Dec 2007 20:06:57 GMT</pubDate></item><item><title><![CDATA[Reply to CreateSolidBrush liefert NULL on Tue, 18 Dec 2007 09:03:19 GMT]]></title><description><![CDATA[<p>Im Endeffekt siehts so aus:</p>
<pre><code class="language-cpp">HBRUSH CDlg::OnCtlColor (CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor (pDC, pWnd, nCtlColor);
    HBRUSH hBGBrush = CreateSolidBrush (RGB(128,184,223));

    if (...)
    {
        HBRUSH hBGEdit = CreateSolidBrush (RGB(0,0,0));
        if (hBGEdit)
            return hBGEdit;
    }

    return hbr;
}
</code></pre>
<p>Wo muss ich ihn deselktieren und zerstören?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422411</guid><dc:creator><![CDATA[Horst2]]></dc:creator><pubDate>Tue, 18 Dec 2007 09:03:19 GMT</pubDate></item><item><title><![CDATA[Reply to CreateSolidBrush liefert NULL on Tue, 18 Dec 2007 09:07:16 GMT]]></title><description><![CDATA[<p>Du erzeugst bei jedem OnCtlColor()-Aufruf einen neuen Brush - und die Funktion wird recht oft aufgerufen (afaik mindestens einmal bei jedem OnPaint). Leg die Objekte lieber einmal am Anfang an und gib sie dann nur noch zurück, wenn sie angefordert werden. (um das (De)Selektieren sollte sich die OnPaint() kümmern, aber das Löschen mußt du selber übernehmen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422413</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422413</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 18 Dec 2007 09:07:16 GMT</pubDate></item><item><title><![CDATA[Reply to CreateSolidBrush liefert NULL on Tue, 18 Dec 2007 09:11:18 GMT]]></title><description><![CDATA[<blockquote>
<p>Leg die Objekte lieber einmal am Anfang an und gib sie dann nur noch zurück</p>
</blockquote>
<p>du meinst als Klassenmember?</p>
<p>Und Löschen dann im Destruktor ...?</p>
<p>Klingt gut, werd ich mal probieren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422414</guid><dc:creator><![CDATA[Horst2]]></dc:creator><pubDate>Tue, 18 Dec 2007 09:11:18 GMT</pubDate></item><item><title><![CDATA[Reply to CreateSolidBrush liefert NULL on Tue, 18 Dec 2007 10:00:39 GMT]]></title><description><![CDATA[<p>Alternativ kannst Du einen schwarzen Pinsel auch über</p>
<pre><code class="language-cpp">HBRUSH hBlackBrush = (HBRUSH) GetStockObject(BLACK_BRUSH);
</code></pre>
<p>abrufen. Dieser muss (und darf) nicht freigegeben werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422448</guid><dc:creator><![CDATA[sri]]></dc:creator><pubDate>Tue, 18 Dec 2007 10:00:39 GMT</pubDate></item></channel></rss>