<?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[Warum wird nicht HOLLOW_BRUSH eingesetzt?]]></title><description><![CDATA[<p>Hallo!<br />
Ich schreibe mir gerade eine Klasse für grafische Funktionen. Ich will auch die Linieneigenschaften, sowohl auch die Farben des Bilds zu beeinflußen.<br />
Ich bin mir fast sicher, dass mit &quot;Pen&quot;-s alles Ok ist. Aber... Diese HBRUSH will einfach nicht richtig funktionieren.<br />
Hier ist ein Teil meiner C++ Code:</p>
<pre><code class="language-cpp">class gdi_vision {
		HDC hdc_;
		HPEN hpen_;
		HBRUSH hbrush_;
	public:
		gdi_vision()
			:hdc_(0), hpen_(0), hbrush_(0) {}

		void init_gd(HDC h) {
			hdc_ = h;
			if(!hpen_)
				hpen_ = CreatePen(PS_SOLID, 1, BLACK);
			SelectObject(hdc_, hpen_);
			if(!hbrush_)
				SelectObject(hdc_, GetStockObject(HOLLOW_BRUSH)); //Am Anfang haben wir HOLLOW_BRUSH!
			else
				SelectObject(hdc_, hbrush_);
		}

		void release_gd() {
			DeleteObject(hpen_);
			hpen_ = 0;
			if(!hbrush_) // falls nicht HOLLOW, dann DELETE IT!
				DeleteObject(hbrush_);
			hbrush_ = 0;
			hdc_ = 0;
		}

		void set_pen(int style, int width, UINT color) { // das funzt OK :)
			hpen_ = CreatePen(style, width, color);
			DeleteObject(SelectObject(hdc_, hpen_));
		}

		void set_solid_brush(UINT color) { // das ist nicht sicher :(
			HBRUSH h = CreateSolidBrush(color);
			if(!hbrush_) //wenn vorher HOLLOW, dann nix machen
				SelectObject(hdc_, h);
			else
				DeleteObject(SelectObject(hdc_, h)); // sonst loeshe vorherige Brush
			hbrush_ = h;
		}

		void set_hollow_brush() { //das will nicht ok funzen! 
			if(!hbrush_) {
				DeleteObject(SelectObject(hdc_, GetStockObject(HOLLOW_BRUSH)));
				hbrush_ = 0;
			}
		}
/*...*/
};
</code></pre>
<p>Und hier die WndProc:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
		static gdi_vision gv;
		HDC hdc;
		PAINTSTRUCT ps;

		switch (message) {
		case WM_CREATE:
			return 0;

		case WM_SIZE:
			return 0;
		case WM_PAINT:
			{
			hdc = BeginPaint (hwnd, &amp;ps);
			gv.init_gd(hdc);
			gv.set_pen(PS_SOLID, 1, Gui::BLACK);
			/*gv.rectangle(10,10,100,100);
			gv.set_pen(PS_SOLID, 4, Gui::CORAL);
			gv.rectangle(50,50,100,100);
			gv.set_pen(PS_DASH, 1, Gui::CHOCO);
			gv.rectangle(80,80,100,100);
			gv.set_pen(PS_DOT, 1, Gui::GREEN);
			gv.rectangle(80,10,100,100);*/ // das funktioniert!

			gv.set_hollow_brush(); // das aber will nicht :(
			gv.ellipse(100,100,600,600);
			gv.set_solid_brush(Gui::DARKBLUE);
			gv.ellipse(100,100,100,700);
			gv.set_solid_brush(Gui::INDIGO);
			gv.ellipse(510,50,300,600);
			gv.set_solid_brush(Gui::YELLOW);
			gv.ellipse(200,400,600,100);
			EndPaint(hwnd, &amp;ps);
			return 0;
			}
		case WM_DESTROY:
			gv.release_gd(); // Pens und Brushes loeschen wir hier!
			PostQuitMessage(0);
			return 0;
		}
		return DefWindowProc(hwnd, message, wParam, lParam);
	}

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/184133/warum-wird-nicht-hollow_brush-eingesetzt</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Jul 2026 11:17:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/184133.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Jun 2007 15:05:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warum wird nicht HOLLOW_BRUSH eingesetzt? on Tue, 12 Jun 2007 15:05:09 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Ich schreibe mir gerade eine Klasse für grafische Funktionen. Ich will auch die Linieneigenschaften, sowohl auch die Farben des Bilds zu beeinflußen.<br />
Ich bin mir fast sicher, dass mit &quot;Pen&quot;-s alles Ok ist. Aber... Diese HBRUSH will einfach nicht richtig funktionieren.<br />
Hier ist ein Teil meiner C++ Code:</p>
<pre><code class="language-cpp">class gdi_vision {
		HDC hdc_;
		HPEN hpen_;
		HBRUSH hbrush_;
	public:
		gdi_vision()
			:hdc_(0), hpen_(0), hbrush_(0) {}

		void init_gd(HDC h) {
			hdc_ = h;
			if(!hpen_)
				hpen_ = CreatePen(PS_SOLID, 1, BLACK);
			SelectObject(hdc_, hpen_);
			if(!hbrush_)
				SelectObject(hdc_, GetStockObject(HOLLOW_BRUSH)); //Am Anfang haben wir HOLLOW_BRUSH!
			else
				SelectObject(hdc_, hbrush_);
		}

		void release_gd() {
			DeleteObject(hpen_);
			hpen_ = 0;
			if(!hbrush_) // falls nicht HOLLOW, dann DELETE IT!
				DeleteObject(hbrush_);
			hbrush_ = 0;
			hdc_ = 0;
		}

		void set_pen(int style, int width, UINT color) { // das funzt OK :)
			hpen_ = CreatePen(style, width, color);
			DeleteObject(SelectObject(hdc_, hpen_));
		}

		void set_solid_brush(UINT color) { // das ist nicht sicher :(
			HBRUSH h = CreateSolidBrush(color);
			if(!hbrush_) //wenn vorher HOLLOW, dann nix machen
				SelectObject(hdc_, h);
			else
				DeleteObject(SelectObject(hdc_, h)); // sonst loeshe vorherige Brush
			hbrush_ = h;
		}

		void set_hollow_brush() { //das will nicht ok funzen! 
			if(!hbrush_) {
				DeleteObject(SelectObject(hdc_, GetStockObject(HOLLOW_BRUSH)));
				hbrush_ = 0;
			}
		}
/*...*/
};
</code></pre>
<p>Und hier die WndProc:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
		static gdi_vision gv;
		HDC hdc;
		PAINTSTRUCT ps;

		switch (message) {
		case WM_CREATE:
			return 0;

		case WM_SIZE:
			return 0;
		case WM_PAINT:
			{
			hdc = BeginPaint (hwnd, &amp;ps);
			gv.init_gd(hdc);
			gv.set_pen(PS_SOLID, 1, Gui::BLACK);
			/*gv.rectangle(10,10,100,100);
			gv.set_pen(PS_SOLID, 4, Gui::CORAL);
			gv.rectangle(50,50,100,100);
			gv.set_pen(PS_DASH, 1, Gui::CHOCO);
			gv.rectangle(80,80,100,100);
			gv.set_pen(PS_DOT, 1, Gui::GREEN);
			gv.rectangle(80,10,100,100);*/ // das funktioniert!

			gv.set_hollow_brush(); // das aber will nicht :(
			gv.ellipse(100,100,600,600);
			gv.set_solid_brush(Gui::DARKBLUE);
			gv.ellipse(100,100,100,700);
			gv.set_solid_brush(Gui::INDIGO);
			gv.ellipse(510,50,300,600);
			gv.set_solid_brush(Gui::YELLOW);
			gv.ellipse(200,400,600,100);
			EndPaint(hwnd, &amp;ps);
			return 0;
			}
		case WM_DESTROY:
			gv.release_gd(); // Pens und Brushes loeschen wir hier!
			PostQuitMessage(0);
			return 0;
		}
		return DefWindowProc(hwnd, message, wParam, lParam);
	}

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1304159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304159</guid><dc:creator><![CDATA[khalderon]]></dc:creator><pubDate>Tue, 12 Jun 2007 15:05:09 GMT</pubDate></item><item><title><![CDATA[Reply to Warum wird nicht HOLLOW_BRUSH eingesetzt? on Tue, 12 Jun 2007 21:26:24 GMT]]></title><description><![CDATA[<p>Hui, was ein Spagetthi-Code <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="😮"
    /> ...ähm</p>
<p>Also wenn ich das richtig überblicke...willst Du damit einfach nur unter allen Umstanden einen HOLLOW_BRUSH einsetzen...:</p>
<pre><code class="language-cpp">void set_hollow_brush() { //das will nicht ok funzen!
            if(!hbrush_) {
                DeleteObject(SelectObject(hdc_, GetStockObject(HOLLOW_BRUSH)));
                hbrush_ = 0;
            }
</code></pre>
<p>...dann doch eher so:</p>
<pre><code class="language-cpp">void set_hollow_brush() {
                DeleteObject(SelectObject(hdc_, GetStockObject(HOLLOW_BRUSH)));
                hbrush_ = 0;
            }
</code></pre>
<p>PS: Kennst Du RAII ? Dem Konzept folgst Du nicht...dabei verwendet man doch genau deswegen Klassen (C++, OOP...)... <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="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1304461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304461</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 12 Jun 2007 21:26:24 GMT</pubDate></item><item><title><![CDATA[Reply to Warum wird nicht HOLLOW_BRUSH eingesetzt? on Wed, 13 Jun 2007 00:44:42 GMT]]></title><description><![CDATA[<p>Ruf mal &quot;gv.release_gd ()&quot; in &quot;WM_PAINT&quot; vor &quot;EndPaint ()&quot; auf und nicht in &quot;WM_DESTROY&quot;.<br />
<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/1304512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304512</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 13 Jun 2007 00:44:42 GMT</pubDate></item><item><title><![CDATA[Reply to Warum wird nicht HOLLOW_BRUSH eingesetzt? on Wed, 13 Jun 2007 15:45:39 GMT]]></title><description><![CDATA[<p>Vielen Dank! Ich habe es mit lokaler Variable, Konstruktor und Destruktor innerhalb WM_PAINT gemacht. Es funzt!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1305007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1305007</guid><dc:creator><![CDATA[khalderon]]></dc:creator><pubDate>Wed, 13 Jun 2007 15:45:39 GMT</pubDate></item></channel></rss>