Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 55
ORA-01403: no data found 43 116
Define unique primary key 9 99
maxBlock challenge 30 150
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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.
Suggested Courses

739 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