Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Win 32 Controls/TTrackBar    [ Add a report in this area ]  
Report #:  4185   Status: Open
TTrackBar's LineSize has no effect on the mouse
Project:  Delphi Build #:  10.166
Version:    10.0 Submitted By:   Thorsten Kettner
Report Type:  Basic functionality failure Date Reported:  4/23/2003 12:40:00 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   240007
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (2 Total Ratings)
3.50 out of 5
Total Votes: None
Description
TTrackBar's properties LineSize and PageSize are used to limit the Position to certain values. This works for the keyboard and for clicking in the empty area of the trackbar (i.e. not on the thumb). But when dragging the trackbar's thumb, the Position gets always incremented or decremented by one instead.

Suggestion: As PageSize works on mouse clicks, LineSize should be used for dragging the thumb with the mouse.
Steps to Reproduce:
Build and run the attached project.
use mouse to drag trackbar
notice it does not increment by steps of ten.

The attached project was created to demonstrate the following steps:

Put a TTrackBar on your form.
Set its Frequency property to 10.
Set its LineSize property to 10.
Set its PageSize property to 10.
Set the Max property to 100.
Put a TLabel on your form.
Write this OnChange event for your trackbar:

void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
  Label1->Caption = TrackBar1->Position;
}

Start the app.
Click on the TrackBar's thumb, hold the mouse button down and drag it right.
The label showing the trackbar's Position gets incremented in steps of one instead of ten.
Workarounds
It is possible to correct the Position in the trackbar's OnChange event:

void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
  if((TrackBar1->Position - TrackBar1->Min) % TrackBar1->LineSize)
    TrackBar1->Position = ((TrackBar1->Position - TrackBar1->Min) / TrackBar1->LineSize) * TrackBar1->LineSize + TrackBar1->Min;
}

(Tested on C++Builder 6 Enterprise, Build 10.166, Windows NT 4.0).
Attachment
qc4185.zip
Comments

None

Server Response from: ETNACODE01