帮忙把这段代码转成C#,谢谢大家了

来源:百度知道 编辑:UC知道 时间:2024/05/04 10:37:08
转完后多给200分,谢谢了

void CArcMapView::OnEditCopy()
{
CWnd *pWndCal =GetDlgItem(IDC_MAPCONTROL1); //get mapcontrol Pointer

CBitmap bitmap;

CClientDC dc(pWndCal); //get dc of mapcontrol client

// Create an in-memory DC compatible with the

// display DC we're using to paint

CDC memdc;

CRect rect;

memdc.CreateCompatibleDC(&dc); //creates a memory device context (DC) compatible with the specified device

pWndCal->GetClientRect(rect); //get mapcontrol envelope(client Rectangle)

//creates a bitmap compatible with the device that is associated with the specified device context

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

CBitmap* poldbitmap = memdc.SelectObject(&bitmap);

memdc.BitBlt(0,0,rect.Width(),rect.Height(),&dc,0,0,SRCCOPY);

//open clipboard

pWndCal->OpenClipboard();

public void CArcMapView:OnEditCopy()
{
CWnd *pWndCal =GetDlgItem(IDC_MAPCONTROL1);
CBitmap bitmap;

CClientDC dc(pWndCal);

CDC memdc;

CRect rect;

memdc.CreateCompatibleDC(dc);

pWndCal.GetClientRect(rect);
bitmap.CreateCompatibleBitmap(dc,rect.Width(),rect.Height());

CBitmap* poldbitmap = memdc.SelectObject(bitmap);

memdc.BitBlt(0,0,rect.Width(),rect.Height(),dc,0,0,SRCCOPY);

pWndCal.OpenClipboard();

EmptyClipboard();

SetClipboardData(CF_BITMAP,bitmap.GetSafeHandle());

CloseClipboard();

memdc.SelectObject(poldbitmap);

bitmap.Detach();

}
我是不怎么看的懂你代码的意思 有些不知道是不是系统自代的函数
如果是 这样就可以了,如果不是的话你就在他前面加上对象.方法