MFC贴图代码段

void CMy07View::OnPaint()
{
    RECT rect;
    CPaintDC dc(this); // device context for painting
   
    // TODO: Add your message handler code here
    CDC *md=new CDC;
    CBitmap *bitmap=new CBitmap;
    GetClientRect(&rect);
    md->CreateCompatibleDC(&dc);//将md转换成与dc兼容的DC

    bitmap->m_hObject=(HBITMAP)::LoadImage(NULL,"/让我动吧.ico",IMAGE_ICON,rect.right,rect.bottom,LR_LOADFROMFILE);

    md->SelectObject(bitmap);
    dc.BitBlt(0,0,rect.right,rect.bottom,md,0,0,SRCCOPY);
    if(md)
        delete md;
    if(bitmap)
        delete bitmap;

    // Do not call CView::OnPaint() for painting messages

你可能感兴趣的:(image,null,delete,mfc)