Click to See Complete Forum and Search --> : Capture a window to a bitmap


Daws
March 29th, 1999, 09:05 AM
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

Alvaro
March 29th, 1999, 04:05 PM
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!