Solved

Drawing a picture in a memory DC?

Posted on 2001-07-01
1
461 Views
Last Modified: 2013-11-20
I have a picture in a CPictureHolder, I need to render this picture in a memory DC then use the memory DC in a  BitBlt function to draw parts of it on the screen.
I wrote some code but it is not working, what did I miss or is it not a valid idea?

void CControl::OnDraw(CDC* pcdc, const CRect& crcBounds, const CRect& crcInvalid)
{
MemoryDC.CreateCompatibleDC(pcdc);
Picture.Render(MemoryDC, crcBounds, crcBounds);
}

cdc->BitBlt(0, 0, nWidth, nHeight, &MemoryDC, 0, 0, SRCAND);
0
Comment
Question by:Daed
[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
1 Comment
 

Accepted Solution

by:
gilad_no earned 100 total points
ID: 6242527
You need to create and attach a bitmap to the memory dc before you use it.

{
CDC memoryDC;
memoryDC.CreateCompatibleDC(pcdc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pcdc,nWidth,nHeight);
CBitmap *oldb=memoryDC.SelectObject(&bitmap);

// now you can work on your memoryDC


pcdc->BitBlt(0,0,nWidth,nHeight,0,0,SRCAND);
memoryDC.SelectObject(oldb);
}

Since you create the memoryDC in the stack, you don't need to destroy it by yourself
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

623 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