可以帮我看看错在什么地方吗?void CTest2View::OnLButtonDown(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
CDC memDc;
CDC scrDc;
HDC dc;
dc=::GetDC(m_hWnd);
CBitmap* pOldBitmap; memDc.CreateCompatibleDC(&scrDc);
scrDc.CreateDC("DISPLAY",NULL,NULL,NULL);
m_rcBitmap.left=0;
m_rcBitmap.top=0;
m_rcBitmap.right=::GetDeviceCaps(dc,HORZRES);
m_rcBitmap.bottom=::GetDeviceCaps(dc,VERTRES); m_myBitmap.CreateCompatibleBitmap(&memDc,100,
100);
pOldBitmap=(CBitmap*)memDc.SelectObject(&m_myBitmap);
memDc.BitBlt(0,0,100,
100,&scrDc,
0,0,SRCCOPY);
CEditView::OnLButtonDown(nFlags, point);
}

解决方案 »

  1.   

    memDc.CreateCompatibleDC(&scrDc); 
    scrDc.CreateDC("DISPLAY",NULL,NULL,NULL); 
    这两句要反过来写吧。你这段代码到底干了些啥呢????
      

  2.   

    memDc.CreateCompatibleDC(&scrDc); 
    scrDc.CreateDC("DISPLAY",NULL,NULL,NULL); 
    首先,这两句写反了我猜你这是捕捉屏幕的,拷屏的,CSDN上有例子,查CreateDC()里面有例子,以下是部分代码:hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL); 
    hdcCompatible = CreateCompatibleDC(hdcScreen); 
     
    // Create a compatible bitmap for hdcScreen. 
     
    hbmScreen = CreateCompatibleBitmap(hdcScreen, 
                         GetDeviceCaps(hdcScreen, HORZRES), 
                         GetDeviceCaps(hdcScreen, VERTRES)); 
     
    if (hbmScreen == 0) 
        errhandler("hbmScreen", hwnd); 
     
    // Select the bitmaps into the compatible DC. 
     
    if (!SelectObject(hdcCompatible, hbmScreen))