Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

difference between CDC & CPaintDC

Posted on 1999-09-22
3
Medium Priority
?
2,624 Views
Last Modified: 2013-11-20
The following are snips use either the CDC or CPaintDC to draw a bitmap to the screen.  The first example doen't do what I would have expected.

void CBunchesObuttonsDlg::OnPaint()
{
  CPaintDC dc(this);
  CDC cdc;
  cdc.CreateCompatibleDC(&dc);
  m_ilButtonStateList.Draw(&cdc, 0,CPoint(50,50), ILD_SELECTED);
  CDialog::OnPaint();
}

However if I use the CPaintDC it works fine.  Why? what is the difference between CDC and CPaintDC.  What would I have to do to make the CDC work?  Please expand/expound.

void CBunchesObuttonsDlg::OnPaint()
{
  CPaintDC dc(this);
  CDC cdc;
  cdc.CreateCompatibleDC(&dc);
  m_ilButtonStateList.Draw(&dc, 0,CPoint(50,50), ILD_SELECTED);
  CDialog::OnPaint();
}

0
Comment
Question by:graber
[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
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2066724
A CDC created with CreateCompatibleDC is a memory DC while CPaintDC (and CClientDC) is a screen DC. You can't see the memory DC, which is used to do some off-screen operation. You have to paint it to the screen DC to see it.
0
 
LVL 2

Author Comment

by:graber
ID: 2066800
This is useful.  Does that mean that any CDC member function I call against a CPaintDC they will be transparent to the screen until I call onPaint?  How do I take the CDC use it to update the screen?  That is the other half of the question.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2066920
In OnPaint, you are responsible for drawing the whole client area of the window. A memory DC is like a buffer. You may draw onto a memory DC and finally copy it to the screen DC by using BitBlt. For more information, see http://members.tripod.com/digitaldawn/section11/section11.html
0

Featured Post

Independent Software Vendors: 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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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