TSplitter.Paint
以绘制比默认的VCL样式cBtnFace
颜色更暗的颜色,但是当调整大小时,表单上会出现明显的闪烁。 有没有办法消除这种闪烁?我尝试了以下方法来尝试减少闪烁,但都没有成功:
Disabling VCL styles (
TSplitter.StyleElements := []
).Changing the VCL Styles Bitmap Style Designer's object element for "Splitter," but modifying this object element doesn't change the splitter's appearance.
Trying to process the
WM_ERASEBKGND
message onTControl
objects, but I was unable to get the procedure to be called in my interposer class.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
的闪烁问题?据我所知,TSplitter
没有DoubleBuffer属性或类似的东西。
更新
不幸的是,我无法分享代码库,但我可以告诉您在TSplitter
闪烁时应用程序UI的设置方式:
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后面(即控件->发送到后面),因此BackgroundPanel上的DoubleBuffered = True和ParentBackground = False将有助于减少/消除其前方任何组件(如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(窗口右侧有黑色轨迹),而不是在应用程序不调整大小时进行其他UI操作时。
更新2
不幸的是,虽然我的上述方法(创建背景父
TPanel
)修复了TSplitter
上的闪烁问题,但它也引起了其他奇怪的UI问题,其中一些可能与@David Heffernan在评论中提到的问题有关。目前,我只留下了闪烁问题,因为分隔线只有1像素宽,并且只在宽度+高度调整大小时闪烁。
TFlickerFreeForm
或TFlickerFreeControl
。 - Jerry DodgeTSplitter
上没有DoubleBuffered
属性。我已经尝试在父 UI 对象上启用DoubleBuffered
,但无济于事。 - spurgeon