19,468
社区成员
发帖
与我相关
我的任务
分享
//
void CScrollBitmapDlg::CopyPictures(HWND hWnd,CPoint point)
{// TODO: Add your message handler code here
UINT ID=::GetDlgCtrlID(hWnd);
// afxDump << ID << " ID\n";
// size
CRect rc;
if(hWnd==0)
{
ID=0;
GetWindowRect(&rc);// the dialog
}
else
{
::GetWindowRect(hWnd,&rc);
}
// create dc
CClientDC dc(this);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
// create empty bmp
HBITMAP bmp=CreateCompatibleBitmap(dc /* not dcMem */, rc.Width(),rc.Height());
dcMem.SelectObject(bmp);
//
CString prompt;
switch (ID)
{
case IDOK:// "Exit"
m_Ok.SendMessage(WM_PAINT,(WPARAM)dcMem.m_hDC,0);
prompt="\"Exit\" button has been copied to clipbroad!";
break;
case IDC_SCROLLBAR1:// "H bar"
m_hBar.SendMessage(WM_PAINT,(WPARAM)dcMem.m_hDC,0);
prompt="\"Horizontal\" scrollbar has been copied to clipbroad!";
break;
case IDC_SCROLLBAR2:// "V bar"
m_vBar.SendMessage(WM_PAINT,(WPARAM)dcMem.m_hDC,0);
prompt="\"Vertical\" scrollbar has been copied to clipbroad!";
break;
case IDC_SHOW:// "Open"
m_Open.SendMessage(WM_PAINT,(WPARAM)dcMem.m_hDC,0);
prompt="\"Open\" button has been copied to clipbroad!";
break;
case IDC_PICTURE:// m_Pic
OnMyPaint((WPARAM)dcMem.m_hDC,0);
prompt="\"CStatic Picture\" has been copied to clipbroad!";
break;
case 0:// the dialog
this->SendMessage(WM_PRINT,(WPARAM)dcMem.m_hDC,
(LPARAM)(PRF_NONCLIENT | PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_OWNED));
prompt="\"The whole dialog\" has been copied to clipbroad!";
break;
}
// move bmp to clipboard
CBitmap *pbmp=dcMem.GetCurrentBitmap();
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP,pbmp->GetSafeHandle());
CloseClipboard();
//
DeleteObject(bmp);
//
AfxMessageBox(prompt);
}