Solved

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

Posted on 1997-12-21
1
304 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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

10 Experts available now in Live!

Get 1:1 Help Now