<?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[GDI+: Absturz beim Zeichnen]]></title><description><![CDATA[<p>Hi @ All.</p>
<p>Ich habe eine Klasse, die ich grade schreiben möchte.</p>
<p>Dabei ist mir aufgefallen, dass wenn ich Draw() aufrufe, oder ein BitBlt des DC machen will, stürzt er ab (==&gt; Debug exception).</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;gdiplus.h&gt;
using namespace Gdiplus;

#pragma once

class CSmartPie
{
public:
	CSmartPie(int nCX, int nCY);
	~CSmartPie(void);
	void Draw(void);

	HDC hDC;
	HBITMAP hBitmap;
	int nWidth, nHeight;

	ULONG_PTR gdiplusToken;

	BYTE bPositive, bNegative;
	BYTE bBackgroundColor[3], bLineColor[3], bPositiveColor[3], bNegativeColor[3];
};
</code></pre>
<pre><code class="language-cpp">#pragma comment(lib,&quot;gdiplus.lib&quot;)
#include &lt;windows.h&gt;
#include &lt;gdiplus.h&gt;
using namespace Gdiplus;

#include &quot;SmartPie.h&quot;

CSmartPie::CSmartPie(int nCX, int nCY)
{
	nWidth = nCX;
	nHeight = nCY;

	// initialize GDI+
	GdiplusStartupInput gdiplusStartupInput;
	GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL); // 02

	hDC = CreateCompatibleDC(GetDC(0));
	hBitmap = CreateCompatibleBitmap(GetDC(0), nWidth, nHeight);
	SelectObject(hDC, hBitmap);

	bBackgroundColor[0] = bBackgroundColor[1] = bBackgroundColor[2] = 255;
	bLineColor[0] = bLineColor[1] = bLineColor[2] = 0;
	bPositiveColor[0] = bPositiveColor[1] = bPositiveColor[2] = 192;
	bNegativeColor[0] = bNegativeColor[1] = bNegativeColor[2] = 192;
}

CSmartPie::~CSmartPie(void)
{
	SelectObject(hDC, hBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hDC);

	GdiplusShutdown(gdiplusToken);  // 03
}

void CSmartPie::Draw(void)
{
	Graphics gPaint(hDC);
	SolidBrush bBackground(Color::MakeARGB(255, bBackgroundColor[0], bBackgroundColor[1], bBackgroundColor[2]));

	gPaint.FillRectangle(&amp;bBackground, Rect(0, 0, nWidth, nHeight));
}
</code></pre>
<p>Ich weiß einfach nicht, woran es liegen könnte. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Danke schonmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/192590/gdi-absturz-beim-zeichnen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 30 Jun 2026 20:02:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/192590.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Sep 2007 15:54:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GDI+: Absturz beim Zeichnen on Sun, 16 Sep 2007 17:22:32 GMT]]></title><description><![CDATA[<p>Hi @ All.</p>
<p>Ich habe eine Klasse, die ich grade schreiben möchte.</p>
<p>Dabei ist mir aufgefallen, dass wenn ich Draw() aufrufe, oder ein BitBlt des DC machen will, stürzt er ab (==&gt; Debug exception).</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;gdiplus.h&gt;
using namespace Gdiplus;

#pragma once

class CSmartPie
{
public:
	CSmartPie(int nCX, int nCY);
	~CSmartPie(void);
	void Draw(void);

	HDC hDC;
	HBITMAP hBitmap;
	int nWidth, nHeight;

	ULONG_PTR gdiplusToken;

	BYTE bPositive, bNegative;
	BYTE bBackgroundColor[3], bLineColor[3], bPositiveColor[3], bNegativeColor[3];
};
</code></pre>
<pre><code class="language-cpp">#pragma comment(lib,&quot;gdiplus.lib&quot;)
#include &lt;windows.h&gt;
#include &lt;gdiplus.h&gt;
using namespace Gdiplus;

#include &quot;SmartPie.h&quot;

CSmartPie::CSmartPie(int nCX, int nCY)
{
	nWidth = nCX;
	nHeight = nCY;

	// initialize GDI+
	GdiplusStartupInput gdiplusStartupInput;
	GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL); // 02

	hDC = CreateCompatibleDC(GetDC(0));
	hBitmap = CreateCompatibleBitmap(GetDC(0), nWidth, nHeight);
	SelectObject(hDC, hBitmap);

	bBackgroundColor[0] = bBackgroundColor[1] = bBackgroundColor[2] = 255;
	bLineColor[0] = bLineColor[1] = bLineColor[2] = 0;
	bPositiveColor[0] = bPositiveColor[1] = bPositiveColor[2] = 192;
	bNegativeColor[0] = bNegativeColor[1] = bNegativeColor[2] = 192;
}

CSmartPie::~CSmartPie(void)
{
	SelectObject(hDC, hBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hDC);

	GdiplusShutdown(gdiplusToken);  // 03
}

void CSmartPie::Draw(void)
{
	Graphics gPaint(hDC);
	SolidBrush bBackground(Color::MakeARGB(255, bBackgroundColor[0], bBackgroundColor[1], bBackgroundColor[2]));

	gPaint.FillRectangle(&amp;bBackground, Rect(0, 0, nWidth, nHeight));
}
</code></pre>
<p>Ich weiß einfach nicht, woran es liegen könnte. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Danke schonmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366436</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 16 Sep 2007 17:22:32 GMT</pubDate></item><item><title><![CDATA[Reply to GDI+: Absturz beim Zeichnen on Sun, 16 Sep 2007 17:07:10 GMT]]></title><description><![CDATA[<p>Initialisiert du GDI+ auch?</p>
<p>(Im &quot;StaticProc&quot; täte ich statt return 0; lieber return DefDlgProc(...); nehmen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366476</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sun, 16 Sep 2007 17:07:10 GMT</pubDate></item></channel></rss>