Roopesh
March 29th, 1999, 05:34 AM
Hi,
I am working on VC++ 5.0.
I want to capture the client area of my application window on to a memory device context. But if there are any other Modeless dialog boxes on the client area of my window, even they get captured.
Is there any way that i can solve this problem..?
Awaiting for ur kind response...
Thank u
lin
March 29th, 1999, 06:12 AM
i think you can bring your window to foreground and get CDC
of current window
Roopesh
March 29th, 1999, 06:51 AM
Thanks a Lot for responding...
Do u have the code for doing the same?
If 'S' please do type in.
Thanks
Waiting.......
Jerry Coffin
March 29th, 1999, 12:36 PM
If you're working in MFC and want to capture a particular view, rather than the entire app's client area, you can
simply invoke OnDraw to do the job:
void CMyView::CaptureClient() {
CBitmap bm;
CRect rect;
CClientDC dc(this);
CDC mem_dc;
GetClientRect(&rect);
bm.CreateCompatibleBitmap(dc, rect.Width(), rect.Height());
mem_dc.CreateCompatibleDC(dc);
mem_dc.SelectObject(bm);
OnDraw(mem_dc);
// bm now contains an image of the client area of your view.
// Do with it as you please...
}
If you need to capture the client area of the entire application, you can _try_ sending it a WM_PAINT message with your
DC's handle in wParam. Putting a DC handle into wParam has been a documented part of WM_PAINT for a few years now, but
MOST applications still ignore it, and always draw to the screen instead. You may have to update the application
you're trying to capture to handle WM_PAINT correctly before this will work. IIRC, if you're using MFC, it does use an
HDC in wParam, but I'd have to check to be sure.