This CreatePen call is failing after repeated calls


HDC hDC;
hDC=GetDC(hWnd);

apen = CreatePen(PS_SOLID, 1, colorG[7]);
oldPen=(HPEN)SelectObject(hDC, apen);

...line drawing stuff...

ReleaseDC(hWnd, hDC);

Apparently a memory leak even with the release

C++.net is the compiler

Any thoughts?

> apen = CreatePen(PS_SOLID, 1, colorG[7]);
So delete/release/free/whatever the pen as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.