Solved

Painting onto a FormView

Posted on 1997-11-02
4
429 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:gav061697
4 Comments
 
LVL 5

Expert Comment

by:dirtdart
ID: 1309164
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);

0
 

Author Comment

by:gav061697
ID: 1309165
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.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1309166
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.
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1309167
What you are trying to do is correct to eliminate flicker. To transfer the image from dc1 to dc, you will need to use CDC::BitBlt().

Although, you probably would want to draw everything to into DC1 and bitblt only the invalid rectangle from dc1 to dc.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 42
Whole sheet autoscrub still needed 19 51
sum67 challenge 35 107
isEverywhere  challenge 19 82
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question