Solved

How to save what I had drawn on a window to LPPICTUREDISP?

Posted on 1997-12-21
1
308 Views
Last Modified: 2013-11-19
I had drawn some lines on a window, how do I copy the picture to LPPICTUREDISP.

0
Comment
Question by:stl
1 Comment
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1312799
You must create memory DC and compatible bitmap. Select this bitmap into DC, force your window to draw itself on this memory DC. Then you must construct CPictureHolder object and use its CreateFromBitmap function passing bitmap you drew on(previously deselected it from memory DC of cause).Then you can get dispatch interface by CPictureHolder::GetPictureDispatch()

CDC memDC;
CDC *pDC = GetDC();
memDC.CreateCompatibleDC(pDC);
CBitmap bitmap;
CRect rc;
GetWindowRect(&rc);
bitmap.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());
CBitmap *pOldBitmap = (CBitmap *)memDC.SelectObject(&bitmap);
//here you must draw your window onto memory DC. If your window //implement WM_PRINT message so you can send this message to //your window passing memory DC handle as WPARAM, otherwise
// you must explicity draw window
memDC.SelectObject(pOldBitmap);
ReleaseDC(pDC);

CPictureHolder pictureHolder;
pictureHolder.CreateFromBitmap(&bitmap);

LPPICTUREDISP lpPictureDisp = pictureHolder.GetPictureDispatch();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

14 Experts available now in Live!

Get 1:1 Help Now