Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TTRackBar Position befroe change



Permlink Replies: 3 - Last Post: May 25, 2017 1:46 AM Last Post By: Paolo Valle
Paolo Valle

Posts: 39
Registered: 8/31/07
TTRackBar Position befroe change
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 24, 2017 9:34 AM
Hello,

I am using a TTrackBar and I need to know the "position" before the change event changes its value, can this be done ?

thank you in advance.
Alex Belo

Posts: 626
Registered: 10/8/06
Re: TTRackBar Position befroe change
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 24, 2017 10:17 AM   in response to: Paolo Valle in response to: Paolo Valle
Paolo Valle wrote:

I am using a TTrackBar and I need to know the "position" before the
change event changes its value, can this be done ?

You can assign current position to Tag property at the end of OnChange
event handler and read this value when OnChange will fire next time.

--
Alex
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TTRackBar Position befroe change
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 24, 2017 10:34 AM   in response to: Paolo Valle in response to: Paolo Valle
Paolo Valle wrote:
I am using a TTrackBar and I need to know the "position" before the change event changes its value, can this be done ?

When the user is changing the "position" visually, TTrackBar receives CN_HSCROLL and CN_VSCROLL messages, which trigger the OnChange event after first updating the Position property. You can subclass the TTrackBar.WindowProc to handle those messages yourself before passing them to TTrackBar for default handling. That way, the Position property will still have the old value.

The OnChange event is also triggered by the Position property setter when setting the property in code or DFM streaming. Subclassing the TTrackBar.WindowProc can also intercept TBM_SETPOS messages before they are processed by Windows. However, TTrackBar updates the Position property before issuing TBM_SETPOS messages to itself.

--
Remy Lebeau (TeamB)
Paolo Valle

Posts: 39
Registered: 8/31/07
Re: TTRackBar Position befroe change
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2017 1:46 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you both.

I have defined a property "OldPosition" that is set at initial value (OldPosition:=Position) and then I update it at the end of OnChange (PS: I need to use the difference Postion-OldPosition for my computing purpose inside the onChange event).

Remy Lebeau (TeamB) wrote:
Paolo Valle wrote:
I am using a TTrackBar and I need to know the "position" before the change event changes its value, can this be done ?

When the user is changing the "position" visually, TTrackBar receives CN_HSCROLL and CN_VSCROLL messages, which trigger the OnChange event after first updating the Position property. You can subclass the TTrackBar.WindowProc to handle those messages yourself before passing them to TTrackBar for default handling. That way, the Position property will still have the old value.

The OnChange event is also triggered by the Position property setter when setting the property in code or DFM streaming. Subclassing the TTrackBar.WindowProc can also intercept TBM_SETPOS messages before they are processed by Windows. However, TTrackBar updates the Position property before issuing TBM_SETPOS messages to itself.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02