Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy entire Document in MFC Window

Status
Not open for further replies.

whodaman

Programmer
May 23, 2001
60
CA
Hi all,
I am trying to copy an entire document in a window, not just the window. I tried the following code:

Code:
void CopyWndToClipboard( CWnd *pWnd )
{
	CBitmap 	bitmap;
	CClientDC	dc(pWnd);
	CDC 		memDC;
	CRect		rect;
	
	memDC.CreateCompatibleDC(&dc); 

	pWnd->GetClientRect(rect);

	bitmap.CreateCompatibleBitmap(&dc, rect.Width(),rect.Height() );

	memDC.s
	CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
	memDC.BitBlt(-2, -32, rect.Width()-19, rect.Height()-33, &dc, 0, 0, SRCCOPY); 

	pWnd->OpenClipboard() ;
	EmptyClipboard() ;
	SetClipboardData (CF_BITMAP, bitmap.GetSafeHandle() ) ;
	CloseClipboard () ;

	memDC.SelectObject(pOldBitmap);
	bitmap.Detach();
}
void CFd4View::OnEditCopy() 
{

//	CWnd* pWnd = GetOwner() ;
	CWnd* pWnd = GetActiveWindow();
//	GetClientRect(*pWnd);

	CopyWndToClipboard(pWnd);
}

But this code only copies the active window and the scroll bars. This document is larger than the window. I would like to copy the entire document into the clipboard. How would I do this?

Thank you in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top