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

    Capture a window to a bitmap



    Hi

    I am trying to capture a specific window and copy it to a bitmap

    My problem is that I only want to capture the window not windows which is ontop of it....

    I have used the code in article "Printing from a CFormView"

    my code look like this...

    CClientDC dc(this);

    if (m_pMemDC->GetSafeHdc()) m_pMemDC->DeleteDC();

    m_pMemDC->CreateCompatibleDC(&dc);

    CRect rect;

    GetClientRect(rect);

    if (m_pBm->GetSafeHandle()) m_pBm->DeleteObject();

    m_pBm->CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());

    m_pMemDC->SelectObject(m_pBm);

    dc.DPtoLP(rect); //Convert to Logical Coordinates

    m_rect = rect; //Save Logical Coordinates

    m_pMemDC->BitBlt(0,0,rect.Width(),rect.Height(),&dc,0,0,SRCCOPY);

    The problem is that windows which is ontop of my window will be captured into my bitmap.


    Thanks

    /David



  2. #2
    Join Date
    Apr 1999
    Location
    Miami, FL
    Posts
    67

    Re: Capture a window to a bitmap



    I don't know of a way to do what you want without first bringing the window to the front to prevent other windows from clobbering it. Bringing it to the front is simple enough: use BringWindowToTop or SetWindowPos.


    Good luck!

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