How can I reduce PageControl flicker in Delphi?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 19:06:41

问题


In Delphi 2009 I found that the flicker of a PageControl - which occurs during resizing of the form - can be reduced by setting its DoubleBuffered property to true.

However if I add controls to the PageControl tabsheets, they will flicker regardless of their DoubleBuffered property setting. I have also tried with and without runtime themes enabled.


回答1:


Setting ParentBackground to False for components on the PageControl helped a lot. However this results in a different color of these panel components, they all have a darker background now. Maybe this can be fixed easily (without losing Theme support).

I also installed VCL Fix Pack which has a fix for QC 56252 (TPageControl flickers a lot with active theming).




回答2:


This is far from perfect, but you might want to use this:

  protected
    procedure WMExitSize(var Message: TMessage); message WM_EXITSIZEMOVE;
    procedure WMEnterSize(var Message: TMessage); message WM_ENTERSIZEMOVE;

procedure TFormMain.WMEnterSize(var Message: TMessage);
begin
  if Assigned(PageControlView.ActivePage) then
    PageControlView.Align := alNone;
end;

procedure TFormMain.WMExitSize(var Message: TMessage);
begin
  if Assigned(PageControlView.ActivePage) then
    PageControlView.Align := alClient;
end;

It's the best I found this far, and will reduce the windows update of your page control. It might be less pretty, though, but that's a matter of opinions...



来源:https://stackoverflow.com/questions/4031147/how-can-i-reduce-pagecontrol-flicker-in-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!