GDI+: Absturz beim Zeichnen
-
Hi @ All.
Ich habe eine Klasse, die ich grade schreiben möchte.
Dabei ist mir aufgefallen, dass wenn ich Draw() aufrufe, oder ein BitBlt des DC machen will, stürzt er ab (==> Debug exception).
#include <windows.h> #include <gdiplus.h> 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]; };#pragma comment(lib,"gdiplus.lib") #include <windows.h> #include <gdiplus.h> using namespace Gdiplus; #include "SmartPie.h" CSmartPie::CSmartPie(int nCX, int nCY) { nWidth = nCX; nHeight = nCY; // initialize GDI+ GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&gdiplusToken, &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(&bBackground, Rect(0, 0, nWidth, nHeight)); }Ich weiß einfach nicht, woran es liegen könnte.

Danke schonmal.
-
Initialisiert du GDI+ auch?
(Im "StaticProc" täte ich statt return 0; lieber return DefDlgProc(...); nehmen)