画图程序没错,我按书上写的,
而且CBitmapButton创建的按钮也没有重绘,怎办?

解决方案 »

  1.   

    不会呀,在OnPaint()中写的一定会重会的
      

  2.   

    onDraw(CDC* pDC ) ;
    {
        //  保存绘图工具
        int iOldDC  = pDC->SaveDC() ;   //   绘图代码
    CBitmap bmpFile ;
    if ( bmpFile.LoadBitmap( IDB_BITMAP1 ) )
    {
    BITMAP bmpInfo;
    bmpFile.GetBitmap(&bmpInfo); // Create an in-memory device context compatible with the
    // display device context that is used to paint.
    CDC dcMemory;
    dcMemory.CreateCompatibleDC(pDC); // Select the bitmap into the in-memory device context.
    CBitmap* pOldBitmap = dcMemory.SelectObject(&bmpFile);
    pDC->BitBlt(rect.left , rect.top , bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,   0, 0, SRCCOPY); dcMemory.SelectObject(pOldBitmap);
    }       //  回复原来的绘图工具
        pDC->RestoreDC( iOldDC ) ;
    }
      

  3.   

    调用该函数:他会强制重新绘制整个客户区
    Invalidate();
    如还不行就加上:
    UpdateWindow();