EDN Admin
Well-known member
Hello All,
I am having a MDI application and developed copy to clipboard functionality to my app. Everything is working fine . The issue is if i click on one of View and some modal dialog
is on the top of my view in that scenario it copies my view along with Dialog to . But i just want that code should copy only the image inside the active view . Not sure what i am doing wrong here .Here is my code
<pre class="prettyprint void XYZ::OnCopyToClipboard()
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
if(pFrame)
{
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
if(pChild)
{
CView *pView = (CView *) pChild->GetActiveView();
if(pView!=NULL)
{
CClientDC cdc(pView);
CDC dc;
dc.CreateCompatibleDC(&cdc);
CRect bounds;
pView->GetClientRect(&bounds);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&cdc, bounds.Width(), bounds.Height());
CGdiSelect<CBitmap> select_bm2(dc, bitmap);
VERIFY(dc.BitBlt(0, 0, bounds.Width(), bounds.Height(), &cdc, bounds.left, bounds.top, SRCCOPY));
BITMAP bmi;
bitmap.GetBitmap(&bmi);
// pass it to clipboard.
if :OpenClipboard(NULL))
{
if:EmptyClipboard())
{
if:SetClipboardData(CF_BITMAP, bitmap.GetSafeHandle()) != NULL)
{
CloseClipboard();
return;
}
}
CloseClipboard();
}
}
}
}
}[/code]
Any one has any idea about it.
Thanks
<
Rupesh Shukla
View the full article
I am having a MDI application and developed copy to clipboard functionality to my app. Everything is working fine . The issue is if i click on one of View and some modal dialog
is on the top of my view in that scenario it copies my view along with Dialog to . But i just want that code should copy only the image inside the active view . Not sure what i am doing wrong here .Here is my code
<pre class="prettyprint void XYZ::OnCopyToClipboard()
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
if(pFrame)
{
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
if(pChild)
{
CView *pView = (CView *) pChild->GetActiveView();
if(pView!=NULL)
{
CClientDC cdc(pView);
CDC dc;
dc.CreateCompatibleDC(&cdc);
CRect bounds;
pView->GetClientRect(&bounds);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&cdc, bounds.Width(), bounds.Height());
CGdiSelect<CBitmap> select_bm2(dc, bitmap);
VERIFY(dc.BitBlt(0, 0, bounds.Width(), bounds.Height(), &cdc, bounds.left, bounds.top, SRCCOPY));
BITMAP bmi;
bitmap.GetBitmap(&bmi);
// pass it to clipboard.
if :OpenClipboard(NULL))
{
if:EmptyClipboard())
{
if:SetClipboardData(CF_BITMAP, bitmap.GetSafeHandle()) != NULL)
{
CloseClipboard();
return;
}
}
CloseClipboard();
}
}
}
}
}[/code]
Any one has any idea about it.
Thanks
<
Rupesh Shukla
View the full article