CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 1999
    Posts
    2

    Capturing the Client Area Of a Window...



    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




  2. #2
    Join Date
    Apr 1999
    Posts
    8

    Re: Capturing the Client Area Of a Window...






    i think you can bring your window to foreground and get CDC

    of current window

  3. #3
    Join Date
    Mar 1999
    Posts
    2

    Re: Capturing the Client Area Of a Window...



    Thanks a Lot for responding...

    Do u have the code for doing the same?

    If 'S' please do type in.

    Thanks

    Waiting.......

  4. #4
    Join Date
    May 1999
    Posts
    123

    Re: Capturing the Client Area Of a Window...



    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured