Ives
Ives

Reputation: 1

Delphi 11 VCL TTrackBar does not have Tracking property, events fire on each tick change

In Delphi FMX, TTrackBar has two events for tracking changes - OnChange and OnTracking. Those two events only do the same thing when Tracking is enabled (by default). Disabling the Tracking will make it so that OnChange is only fired after the user is finished.

My problem is that using Delphi 11 for a VCL application, the Tracking property does not exist, and the events fire with each change/tick instead at the end (resulting in sending multiple messages).

I would prefer only the end change / last value), according to this older post:

Delphi TTrackBar doesn't have on complete event

Upvotes: 0

Views: 339

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596407

TTrackBar in VCL does not have an event when tracking is finished. However, the underlying Win32 Trackbar control does send such notifications.

It sends WM_HSCROLL/WM_VSCROLL messages (depending on its orientation) to its parent window, where the LOWORD(wParam) is set to TB_ENDTRACK. You can subclass the parent window to handle these notifications.

It can also send a TRBN_THUMBPOSCHANGING notification to the parent window, where the lParam holds a pointer to a NMTRBTHUMBPOSCHANGING struct, whose nReason field is set to TB_ENDTRACK. You can subclass the TTrackBar itself to catch CN_NOTIFY messages to handle this notification.

Upvotes: 4

Related Questions