How do I know when I stopped scrolling a TScrollBar?

I used some scroll list programs that update related content while you still drag the thumb, while others only until you release the mouse. This means that various types of Windows messages are used here. But all I can find in the TScrollBar is the OnScroll event, which fires constantly during drag and drop. It also does not have OnMouseDown or OnMouseUp events. Is there a way to configure the "OnEndDragging" notification for a TScrollBar?

+3
source share
2 answers

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.

+5
source

Programs that update their scroll area live when the user drags their thumb handle the code sb_ThumbTrackfor wm_HScrolland wm_VScroll. Those that are updated only when the user releases the thumb process the code sb_ThumbPosition.

, , , . sb_ThumbTrack, . , . sb_ThumbTrack, reset .

+2

Source: https://habr.com/ru/post/1718961/


All Articles