CreateDCRenderTarget
(1)
DCRenderTarget
(1)
BindDC
(1)
RenderTarget
(1)
BeginDraw
(1)
EndDraw
(1)
MFactory
(1)
MTarget
(1)

Access violation with BindDC

Asked By docschnipp
02-Nov-09 05:53 PM
Hi,

I am trying to keep my DCRenderTarget and on WM_PAINT, I am trying to reuse
it by just calling BindDC.

This works fine the first time, when I just created the render target.

Calling Sequence is:

if (!mTarget)
{
mFactory->CreateDCRenderTarget(...,mTarget);
}
mTarget->BindDC(dc,rect);
mTarget->BeginDraw();
....
// now comes stuff like loading bitmaps and drawing...
....
mTarget->EndDraw(); // D2D_RECREATE_TARGET is handled, too

the next time, WM_PAINT calls this sequence, BindDC fails with an Access
Violation:

First-chance exception at 0xfeeefeee in graphics.exe: 0xC0000005: Access
violation.

What am I missing? Is there something more I need to do to be able to reuse
a target?

Thanks
doc

"docschnipp" wrote:I think I know what the problem is: I ->Release()'d an

docschnipp replied to docschnipp
03-Nov-09 03:43 PM
I think I know what the problem is: I ->Release()'d an object (a brush) that
was tied to the Target. I thought, by calling "Release()" it would also get
away from the Target, but obviously it is not.

Is there a way to remove an object like a brush or a bitmap from a
RenderTarget?
Or must I keep them all in it?

thanks
doc
Post Question To EggHeadCafe