Link to home
Start Free TrialLog in
Avatar of Yevgen
Yevgen

asked on

Temp DC

I have a program with SDI document and i'm drawing all kinds of things on the client area. What i did was to call Draw functions of all object that should be drawn from the View class Draw function.

My problem is that it draws everything slowly. What i tried was to create a temp CDC object and send it to the draw functions and when it returns copy it to the active DC. I tried using BitBlt but it doesnt work. How can i do this?
Avatar of KurtVon
KurtVon

You may need to call CreateCompatableBitmap on the DC, then select the bitmap into the DC.  If you just create a DC it has a monochrome one pixel bitmap by default.

If that isn't the problem you really will need to provide a code sample or more details.
Avatar of Yevgen

ASKER

Can you show me how to do this. I need the temp DC to be the same size as the main DC.

Tnx...
ASKER CERTIFIED SOLUTION
Avatar of KurtVon
KurtVon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yevgen

ASKER

That works but the bitmap is monochrome and the background is black. Can you help me with this one?
Whoops.

Change the &dcMem in the CreateCompatibleBitmap to &paintDC.

Like I said, the default bitmap is monochrome.
Avatar of Yevgen

ASKER

Tnx, one last thing... The pixels which i dont use are filled with random colors, can i somehow clean them?
Before drawing do a PatBlt with WHITENESS, or, to be more compatible, do a FillRect with a brush the color of the window:

CBrush brBackground(::GetSysColor(COLOR_WINDOW));
dcMem.FillRect(rcClient, brBackground); // rcClient always has (0, 0) as upper left.

Oh, and since you don't need it, override OnEraseBkgnd and just return TRUE so the system doesn't bother filling the window for you.