Solved

Painting onto a FormView

Posted on 1997-11-02
4
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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