Solved

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

Posted on 1997-12-21
1
311 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 149
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 513
Replacement selected text 2 65
Problem to App 4 116
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

740 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