delphivclvcl-stylesdelphi-12-athens

VCL high DPI style prevents proper scroll bar sizing. How do I force the scrollbar to redraw?


Using Delphi 12.1 Athens:

This has been acknowledged as a defect, but I haven't gotten any advice about a workaround. I thought I could simply resize the main window, and that works unless the window is maximized, which a lot of my users do. I tried simply calling the Resize() method, but that had no effect. I tried tracing through the VCL code, but I could not find anything that made sense to me.

object MainForm: TMainForm
  Left = 194
  Top = 111
  Caption = 'MDI Application'
  ClientHeight = 535
  ClientWidth = 610
  Color = clAppWorkSpace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBlack
  Font.Height = -11
  Font.Name = 'Default'
  Font.Style = []
  FormStyle = fsMDIForm
  VisualManager = FormTabsBar1
  Position = poDefault
  TextHeight = 13
  object StatusBar: TStatusBar
    Left = 0
    Top = 516
    Width = 610
    Height = 19
    Margins.Left = 2
    Margins.Top = 2
    Margins.Right = 2
    Margins.Bottom = 2
    AutoHint = True
    Panels = <>
    SimplePanel = True
  end
  object FormTabsBar1: TFormTabsBar
    Left = 0
    Top = 486
    Width = 610
    Height = 30
    Align = alBottom
    ParentColor = False
    TabOptions.ShowFormIcon = True
    TabOptions.ShowFormSystemMenu = True
    TabOptions.ShowCloseButton = True
    TabOptions.ShowHintForTruncatedCaption = True
    TabMinWidth = 100
    TabMaxWidth = 250
    Visible = False
    ShowTabsMenuButton = True
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 610
    Height = 97
    Align = alTop
    Caption = 'Panel1'
    TabOrder = 2
    OnClick = Panel1Click
    object NewBtn: TButton
      Left = 20
      Top = 28
      Width = 75
      Height = 25
      Caption = 'NewBtn'
      TabOrder = 0
      OnClick = NewBtnClick
    end
  end
  object OpenDialog: TOpenDialog
    Filter = 'All files (*.*)|*.*'
    Left = 16
    Top = 272
  end
  ... Image data removed...
end
procedure TMainForm.Panel1Click(Sender: TObject);
begin
  if Panel1.Height > 100 then
    Panel1.Height := Panel1.Height - 20
  else
    Panel1.Height := Panel1.Height + 20;
end;
    
procedure TMainForm.NewBtnClick(Sender: TObject);
begin
  FileNew1Execute(nil);
end;

Solution

  • You can use this workaround inside the Panel1Click event handler and include Vcl.Themes in the uses list:

    SendMessage(Handle, WM_MDICHILDMOVE, 0, 0);