对话框无法重新绘制 [英] dialog box fails to re-paint

查看:108
本文介绍了对话框无法重新绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

请原谅下面的代码.我现在只是在骇客.
我有一个问题,基本上下面的代码显示3张图像.
第一个图像显示背景,其余两个较小的图像是简单徽标.它呈现的很好,但是当我拖动对话框时.无法重新绘制背景吗?

有人会这么友善并启发我解决这个问题以及如何解决它.我的记忆确实不好.

谢谢,
加里克

Hello,

Please excuse the code below. I''m just hacking at the moment.
I have a question, essentially the below code displays 3 images.
The 1st image displays the background, and the remaining 2 smaller images are simple logos. It renders fine, however when I drag the dialog box. It fails to re-paint the background?

Could somebody be so kind and enlighten me on this problem and how to resolve it. My memory is indeed bad.

Thanks,
Garyc

 void CtesterDlg::OnPaint()
   {
   	CPaintDC dc( this ); // Device context for painting
         CBitmap bmp, *poldbmp;
         CDC memdc;
        	  // Load the bitmap resource
		 bmp.LoadBitmap(IDB_BITMAP1);
         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         // Copy (BitBlt) bitmap from memory DC to screen DC
         dc.BitBlt(0, 0,2000,4000, &memdc, 0, 0, SRCCOPY );   

         // Copy (BitBlt) bitmap from memory DC to screen DC
    
       
         memdc.SelectObject( poldbmp );
		   // Load the bitmap resource
		 bmp.LoadBitmap(IDB_BITMAP2);
         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         // Copy (BitBlt) bitmap from memory DC to screen DC
         dc.BitBlt(20,320,400,400, &memdc, 0, 0, SRCCOPY );
		  memdc.SelectObject( poldbmp );
		   // Load the bitmap resource
		 bmp.LoadBitmap(IDB_BITMAP3);
         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         // Copy (BitBlt) bitmap from memory DC to screen DC
         dc.BitBlt(550,320,450,6000, &memdc, 0, 0, SRCCOPY );
}

推荐答案

:)

启示1:每次使用后尝试memdc.DeleteDC()
启蒙0:我们应该尝试通过调试(行,堆栈,var,regs ...)来分析每个断言/异常.
:)

Enlightenment 1: Try memdc.DeleteDC() after its each usage
Enlightenment 0: We should try to analyze every assertion/exception by debugging (line, stack, vars, regs...)


尝试刷新对话框.

CDialog :: Invalidate(1);
CDialog :: UpdateWindow();
try refreshing the dialog box.

CDialog::Invalidate(1);
CDialog::UpdateWindow();


这篇关于对话框无法重新绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆