[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

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

I had drawn some lines on a window, how do I copy the picture to LPPICTUREDISP.

0
stl
Asked:
stl
1 Solution
 
galkinCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now