调整自定义MFC控件大小时Win7刷新问题 [英] Win7 refresh problem when resizing custom MFC controls

查看:59
本文介绍了调整自定义MFC控件大小时Win7刷新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在编写一个程序,该程序具有我自己编写的自定义图形控件(就像任务管理器的图形一样).我通常在WinXP上运行该程序,一切都很好.

我在Win7上进行了测试,发现了一个令人讨厌的刷新问题.实际上,控件在调整大小时会缩小为白色矩形.矩形已经过调整大小,但是内部只能看到白色,在我调整大小后,它们会像这样保持不变.

这些控件每秒都会刷新一次,因此在我调整大小后,它们的内容会在一秒钟内显示出来,但是没有沉没的客户端边缘,这会使它们看起来很丑陋.而且,所有标准控件都没有此问题.只有我自定义的.

我通过在对话框资源中设置静态文本控件(设置了border属性)来设置这些控件,然后将其控件变量设置为CWnd继承类的类,该类在OnPaint 处进行绘制(标准的东西我只说这是为了清洁).

起初,我发现这是由于pDC->ExcludeClipRect(&CtrlRect);导致我在OnEraseBkgnd处打电话的原因.它在WinXP中具有出色的防闪烁效果.因此,我构建了一个程序,其中删除了所有OnEraseBkgnd函数中的所有代码(设置为注释),以便这些函数调用具有其默认行为.
-完全没有效果-一样.所以显然这不是问题.

我在OnSize处设置了RedrawWindow 呼叫,此呼叫可以解决此问题,但是性能非常低效,并且闪烁非常糟糕.

那么有人遇到过这个问题吗?如果可以做某事,那将是很棒的.我用谷歌搜索后发现,两年前有人遇到了非常相似的问题,他直接将问题提交给了MS支持人员,他们表示将对此进行调查. :)

提前致谢! :)

P.S.如果需要任何其他信息,请随时询问我.

Hi All

I''m writing a program that has custom graphic controls (just like task manager''s graphs) which I coded myself. I''m usually running the program on WinXP and everything is fine.

I tested it on Win7 and I saw a nasty refresh problem. Virtually the controls are reduced to white rectangles while resizing. The rectangles are resized as it should but nothing but white can be seen inside them, and they stay like this after I finish resizing.

These controls are refreshed each second so after I finish resizing their content is shown within a second but without the sunken client edge which makes them look ugly. And Also none of the standard controls has this problem. only my custom ones.

I set these controls by placing a static text control in the dialog resource (with border property set) and then I set their control variable to be of my CWnd heired class that does the drawing at OnPaint (standard stuff I say this just for cleanness).

At first I figured it was because of pDC->ExcludeClipRect(&CtrlRect); I call at OnEraseBkgnd. It has wonderful anti-flicker effect in WinXP. So I made a build of my program having all that code in all OnEraseBkgnd funcs deleted (set as comments) so those function calls have their default behaviour.
- Absolutely no effect - it was just the same. So obviously that''s not the problem.

I set a RedrawWindow call at OnSize which fixes the issue but that''s very performance ineffective and the flicker is awful.

So does somebody encountered this problem? It''d be great if something can be done. I''ve googled this and all I found was that 2 years ago someone had very similar problem and he addressed it directly to MS support and they''ve said they''ll look into it. :)

Thanks in advance! :)

P.S. If any additional info is needed please don''t hesitate to ask me for it.

推荐答案

快速而肮脏的方法是使用LockWindowUpdate
http://msdn.microsoft.com/en-us/library/dd145034% 28VS.85%29.aspx [ ^ ]

但是,最好使用WM_SETREDRAW进行此操作.

推荐使用cal BeginPaint,完成后再调用EndPaint.
http://msdn.microsoft.com/en-us/library/dd183362%28v = VS.85%29.aspx [ ^ ]

祝你好运!
The quick and dirty way would be to use LockWindowUpdate
http://msdn.microsoft.com/en-us/library/dd145034%28VS.85%29.aspx[^]

But, it would be better to use the WM_SETREDRAW to do this.

Recommended would be to cal BeginPaint and when done call EndPaint.
http://msdn.microsoft.com/en-us/library/dd183362%28v=VS.85%29.aspx[^]

Good luck!


越来越多的我确信我的程序没有任何问题,这是Windows 7本身的一个错误!
-首先,我在其他(基于对话框的可调整大小的)程序上看到了这一点,其中有些喜剧内容!
-同样,在最近的Windows Update之后,此问题的一部分也消失了.当我打开文件夹时,Tab控件内部对话框的表面变为白色,并且变成灰褐色(正常对话框的颜色),而背景中立即显示静态文本的部分仍然保留正常的颜色看起来非常难看.现在,在更新(Windows Update)之后,这种效果就消失了!剩下的就是我在问题主体中描述的内容.

我测试了以上答案提供的两种解决方案,但它们均无效.我不想拒绝该解决方案,因为我不确定我是否做对了所有事情,还必须测试更多...
More and more I get convinced that there is nothing wrong with my program and this is a BUG of Windows 7 itself!!!

- Firstly I saw this on oher (Dialog based resizing capable) programs, some of which cometial!
- Also after recent Windows Update part of this problem disappeared. The part that when I open a folder the face of the dialog that is inside the Tab control becomes white and it''s sopposed to be this grey-brown color (the normal dialog color) while the background immediately behing any static text remains with the normal color which looks very ugly. Now after the update (Windows Update) this effect is gone! What remains is what I''ve described in the main body of my question.

I tested both solutions offered by the above answer and they both didn''t work. I don''t want to reject the solution because I''m not sure I did everything right and I have to test some more ...


这篇关于调整自定义MFC控件大小时Win7刷新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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