内存缓冲作图

void  C *** View::OnPaint() 
{
    CPaintDC dc(
this); 
    RECT rect;
    GetClientRect(
&rect);
    CBitmap 
*bitmap;
    bitmap
=new CBitmap;
    bitmap
->m_hObject=(HBITMAP)::LoadImage(NULL,"0.bmp",IMAGE_BITMAP,rect.right,rect.bottom,LR_LOADFROMFILE);

    CDC 
*mdc;
    mdc
=new CDC;
    mdc
->CreateCompatibleDC(&dc);
    mdc
->SelectStockObject(BLACK_BRUSH);
    mdc
->SelectObject(bitmap);//先加载位图
    mdc->Rectangle(0,0,300,300);    //再操作内存dc作图
    dc.BitBlt(0,0,rect.right,rect.bottom,mdc,0,0,SRCCOPY);//拷贝显示
    delete mdc;
}

你可能感兴趣的:(内存)