我使用德尔福VCL样式启用,我想改变我的窗体TSplitter的颜色。我在介入类中覆盖了TSplitter.Paint
以绘制比默认VCL样式暗的颜色cBtnFace
颜色,但调整大小时窗体上会出现明显的闪烁。有没有办法消除这种闪烁?德尔福TSplitter闪烁问题
我已经试过这些东西,试图减少闪烁,但没有工作:
禁用VCL样式(
TSplitter.StyleElements := []
)。更改“Splitter”的VCL样式位图样式设计器的对象元素,但修改此对象元素不会更改分隔符的外观。
试图在
TControl
对象上处理WM_ERASEBKGND
消息,但我无法获取要在我的插入器类中调用的过程。procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND; ... procedure TSplitter.WMEraseBkgnd(var Msg: TWMEraseBkgnd); begin // this is never invoked by the TSplitter Msg.Result := 1; end;
任何其他如何在TSplitter
摆脱闪烁?没有DoubleBuffer属性TSplitter
或类似的东西,我可以告诉。
UPDATE
不幸的是,我不能共享代码库,但我可以告诉你,这是应用程序用户界面的安装方式时TSplitter
闪烁:
TForm (DoubleBuffered = False)
-> BackgroundPanel (DoubleBuffered = True, ParentBackground = False)
-> -> A TGradient, image and label to fill the BackgroundPanel
-> LeftPanel (ParentBackground = False`, no flickering)
-> -> LeftPanelFrame and frame content (selective double buffering)
-> TSplitter
-> RightPanel (ParentBackground = False, no flickering)
-> -> RightPanelFrame and frame content (selective double buffering)
有还有一个工具栏和位于窗体顶部的主菜单,但其余的UI组件被设置为alClient(或OnResized以填充空间)。
我以为,既然BackgroundPanel是LeftPanel,TSplitter
和RightPanel背后(即控制 - >发送到后),该DoubleBuffered = True
和ParentBackground = False
在BackgroundPanel将有助于减少/从任何部件上立即消除闪烁在它前面的UI层(即,TSplitter
)。但是,这似乎并非如此。
也许我会尝试把一个TPanel
作为LeftPanel,TSplitter
,并且RightPanel的父母,并设置其DoubleBuffered = True
和ParentBackground = False
。我将不得不在稍后尝试并返回。因此,它应该是这样的:
TForm
-> BackgroundPanel (DoubleBuffered = True, ParentBackground = False)
-> -> A TGradient, image and label to fill the BackgroundPanel
-> EncapsulatingPanel (DoubleBuffered = True, ParentBackground = False)
-> -> LeftPanel (ParentBackground = False)
-> -> -> LeftPanelFrame and frame content
-> -> TSplitter
-> -> RightPanel (ParentBackground = False)
-> -> -> RightPanelFrame and frame content
最后,我要指出,双缓冲TForm的调整(在窗口右侧的黑色痕迹)时,极大地降低了用户界面,没有做其他的UI事情时,当应用程序没有调整大小时。
更新2
不幸的是,而我的上面(创建一个背景父TPanel
)的方式固定在TSplitter
闪烁,也引起其他奇怪的UI问题,也许其中有一些@大卫赫弗南暗示在评论。目前,我刚刚离开了闪烁的问题,因为分离器只有1px宽,只在宽度+高度调整大小时闪烁。
我还在等待引入'TFlickerFreeForm'或'TFlickerFreeControl'。 – 2013-04-04 21:56:39
远程获取并且有时候解决方案不足,但是您是否尝试启用'DoubleBuffered'? – 2013-04-04 21:57:57
@JerryDodge'TSplitter'没有DoubleBuffered属性,如果这就是你的意思(我的问题的底部)。我试过对父UI对象启用'DoubleBuffered'无济于事。 – spurgeon 2013-04-04 22:03:30