用程式碼操縱剪下板
阿新 • • 發佈:2019-01-07
if ( OpenClipboard() )
{
EmptyClipboard();
//create some data
CBitmap * junk = new CBitmap();
CClientDC cdc(this);
CDC dc;
dc.CreateCompatibleDC(&cdc);
CRect client(0,0,200,200);
junk->CreateCompatibleBitmap(&cdc,client.Width(),client.Height());
dc.SelectObject(junk);
//call draw routine here that makes GDI calls
DrawImage(&dc,CString("Bitmap"));
//put the data on the clipboard
SetClipboardData(CF_BITMAP,junk->m_hObject);
CloseClipboard();
//copy has been made on clipboard so we can delete
delete junk;
}
{
EmptyClipboard();
//create some data
CBitmap * junk = new CBitmap();
CClientDC cdc(this);
CDC dc;
dc.CreateCompatibleDC(&cdc);
CRect client(0,0,200,200);
junk->CreateCompatibleBitmap(&cdc,client.Width(),client.Height());
dc.SelectObject(junk);
//call draw routine here that makes GDI calls
DrawImage(&dc,CString("Bitmap"));
//put the data on the clipboard
SetClipboardData(CF_BITMAP,junk->m_hObject);
CloseClipboard();
//copy has been made on clipboard so we can delete
delete junk;
}