本文介绍了如何同时更改控件,而不需要重新绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我需要在运行时禁用两个按钮。当我禁用第一个按钮后,它会变灰,第二个 - 它也变灰了。但我不知道如何使重画同时进行!我需要这样的东西:
- 冻结Form(禁用重绘)
- 禁用第一个按钮
- 禁用第二个按钮
- 启用重新绘制表单
如何实现?
解决方案
查看Win32 API WM_SETREDRAW
消息。例如:
SendMessage(Handle,WM_SETREDRAW,False,0);
Button1.Enabled:= False;
Button2.Enabled:= False;
SendMessage(Handle,WM_SETREDRAW,True,0);
InvalidateRect(Handle,nil,True);
For example I need to disable two buttons in runtime. After I disabled first button it bacame gray, the second - it also became gray. But I do not know how to make the repainting simultaneous!
I need something like that:
- freeze the Form (disable repainting)
- disable first button
- disable second button
- Enable Form repainting
How to implement that?
解决方案
Look at the Win32 API WM_SETREDRAW
message. For example:
SendMessage(Handle, WM_SETREDRAW, False, 0);
Button1.Enabled := False;
Button2.Enabled := False;
SendMessage(Handle, WM_SETREDRAW, True, 0);
InvalidateRect(Handle, nil, True);
这篇关于如何同时更改控件,而不需要重新绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!