如何处理MFC listcontrol窗口闪烁? [英] How to deal with MFC listcontrol window flashing?

查看:747
本文介绍了如何处理MFC listcontrol窗口闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个MFC应用程序。我在对话框中使用了一些ListControl控件和一些单选按钮。我想用ListControl实现实时更新数据,点击单个单选按钮触发相应的事件。



首先,当对话框初始化时,将数据插入ListControl并显示对话框。



其次,当我点击时这些中的一个radiobutton。第一步是删除ListControl中的所有列和所有项目。第二步是将我的必要数据插入ListControl。顺便说一句,我使用了相对于ListControl ID的相同变量。



注意:数据随时间变化了!



最后我发现ListControl窗口出现了快速闪光,感觉很糟糕。

那么有什么好方法可以解决这个问题吗?你能给我一些好的或高级的建议吗?非常感谢!



我尝试过的事情:



我尝试的方式无效......

I wrote a MFC application program.I used some ListControl controls and some radio buttons in the dialog.I would like to realize real-time-update data with ListControl when clicked the single radiobutton triggering the corresponding events.

Firstly,when the dialog initialized,inserting data into the ListControl and showing the dialog.

Secondly,when I clicked the one radiobutton among these.The first step was to delete the all columns and all items in the ListControl.The second step was to insert my neccessary data into the ListControl.By the way,I used the same variable relative to the ListControl ID.

Notice:The data was changed by time!

Finally I found that the ListControl window appeared the fast flash and felt so bad.
So is there some good ways to solve this problem?And can you suggest some good or advanced advice to me?Thanks a lot!

What I have tried:

The ways I've tried were not valid...

推荐答案

最简单的解决方案是在更新列表时禁用绘图。

The simplest solution is disabling drawing when the list is updated.
m_ListCtrl.SetRedraw(0);

// Update list here

m_ListCtrl.SetRedraw(1);
// Invalidate entire control
// May also use InvalidateRect() for a specific area
m_ListCtrl.Invalidate();
// Force redrawing
m_ListCtrl.UpdateWindow();



如果可能,您应该只更改列表的某些部分,而不是替换完整的内容。当这些不会改变时,通常也不需要删除列。





你也可以设置 LVS_EX_DOUBLEBUFFER 扩展列表视图样式(Windows) [ ^ ]以减少闪烁。

[/ EDIT]


If possible you should only change portions of the list instead of replacing the complete content. Also there is often no need to remove the columns when those will not change.


You may also set the LVS_EX_DOUBLEBUFFER Extended List-View Styles (Windows)[^] to reduce flickering.
[/EDIT]


这篇关于如何处理MFC listcontrol窗口闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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