How do I change the width of the ScrollBar?
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 to share
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 to share