Link to home
Start Free TrialLog in
Avatar of gav061697
gav061697

asked on

Painting onto a FormView

I have this code in the OnPaint function of my FormView:

void CMyFormView::OnPaint()
{
      CPaintDC dc(this); // device context for painting
      CDC dc1;
      dc1.CreateCompatibleDC( &dc );

        dc1.TextOut(0,138, player1_name);
}

What I want to know is from this, how to I transfer the dc1 image to the dc?

I'm doing this as I paint graphics directly onto the form and they flash when they're updated so I believe that painting everything to dc1 first then transfering it to the dc I will eliminate the flicker.

Is this the right way to do it?
Avatar of dirtdart
dirtdart

Why not just Skip the CDC completly.  You can use the TextOut Win32 function instead of the CDC.TextOut function.  The only difference is that you need to and the hDC to the beginning of the call, like this:

TextOut(hDC, 0, 138, palyer1_name);

Avatar of gav061697

ASKER

Just displaying text is fine...in the program I'm writing, I display bitmaps on the FormView aswell...and sometimes only some of them need redrawing...when I do this I repaint each bitmap separately which causes a flicker.
I think if you create a static control on the form and simply paint onto this static control either directly from the formview or either derive your class CMyStatic for this static control and then make a painting and redrawing call for the class. You should be able to only paint this control and not bother painting other controls.
ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

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