Try this code (tested with Delphi 2009), it will fill the area of ββthe form form with random color while you trace the thumb, and fill it with yellow when the thumb is released:
procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
Randomize;
if ScrollCode = scTrack then
Color := RGB(Random(256), Random(256), Random(256));
if ScrollCode = scEndScroll then
Color := clYellow;
end;
The values TScrollCodecorrespond to the values WPARAMthat you will find documented for WM_HSCROLLand WM_VSCROLL.
source
share