Solved

Painting onto a FormView

Posted on 1997-11-02
4
394 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now