<< Click to Display Table of Contents >> Navigation: Programming > User Interface > Modify the look and feel of the editor > Custom Scrollbars |
You can also attach different scroll bars. To do so, use the event OnUpdateExternScrollbar:
The event OnUpdateExternScrollbar makes it possible to update the position of an external scrollbar. The parameters are automatically limited to a maximal value of 20000 my calculating a multiplicator value.
This values are accessible through the properties ScrollVertMultiplicator and ScrollHorzMultiplicator.
// Update the position of the scrollbar
procedure TForm1.WPRichText1UpdateExternScrollbar(
Sender: TWPCustomRtfEdit;
ScrollBar: TScrollStyle;
Range, Page,Pos: Integer);
begin
if ScrollBar=ssVertical then
begin
ScrollBar1.PageSize := Page;
ScrollBar1.Max := Range;
ScrollBar1.Position := Pos;
end;
end;
// Change position when Scroll event happens
procedure TForm1.ScrollBar1Scroll(Sender: TObject;
ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
WPRichText1.TopOffset := Round(ScrollPos / WPRichText1.ScrollVertMultiplicator);
end;