How do I change the width of the ScrollBar?

I would like to change the scroll width of the TFrame.
I know I can change all the ScrollingBars on the system:

SystemParametersInfo(SPI_SETNONCLIENTMETRICS,....

      

But how do you do this for a specific WinControl?

+2


source to share


3 answers


Most of the code in Delphi relies on the width of the scrollbars as a fixed system setting, so you cannot change the width without breaking control. (Without rewriting TControlScrollBar and its associated controls in the VCL.)

You could, of course, hide the default scrollbars of the control and add your own TScrollbar components next to it.




The standard TScrollBar class is WinControl itself, where the scrollbar takes the full width and height of the control. The TControlScrollBar class links to another WinControl to control the default scrollbars that are assigned to Windowed controls. While the original API could have used a more flexible width, you will always have the problem that the VCL will simply assume a default width for these elements.

This also shows the biggest difference between scroll types: TScrollBar has its own Windows handle, while TControlScrollBar takes it from the corresponding control.

+1


source


You can try something like this:



  your_frame.HorzScrollBar.Size := 50;
  your_frame.HorzScrollBar.ButtonSize := your_frame.HorzScrollBar.Size;

      

+1


source


procedure TForm1.FormCreate(Sender: TObject);
var NCMet: TNonClientMetrics;
begin
     FillChar(NCMet, SizeOf(NCMet), 0);
     NCMet.cbSize:=SizeOf(NCMet);
     // get the current metrics
     SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(NCMet), @NCMet, 0);
     // set the new metrics
     NCMet.iScrollWidth:=50;
     SystemParametersInfo(SPI_SETNONCLIENTMETRICS, SizeOf(NCMet), @NCMet, SPIF_SENDCHANGE);
end;

      

-1


source







All Articles