Solved

Painting onto a FormView

Posted on 1997-11-02
4
439 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 102
tripleUp challenge 7 93
sumHeights  challenge 17 80
Problem to Office 1 45
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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