Delphi
--
Questions
--
Followers
Top Experts
trackbar position before click
---|----------------
mouse click on the trackbar near the end
------------------|--
I know the trackbar will step towards the pointer but I want to do it in one movement not steps.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Save the following as a unit and then install the component. The new TrackBarC
will be found on the samples palette. It works for horizontal bars. I'll leave it
to you for vertical. This was a good example of making delphi work for you
especially when an existing property is not published (OnMouseDown).
unit TrackBarC;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls;
type
TTrackBarC = class(TTrackBar)
public
property OnMouseDown;
constructor Create(AOwner: TComponent); override;
procedure MouseDownC(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample
end;
constructor TTrackBarC.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
OnMouseDown:=MouseDownC;
end;
procedure TTrackBarC.MouseDownC(Send
var
Offset,Space:Integer;
begin
Space:=11;
Offset:=X-Space;
Position:=Round(Min+Offset
end;
end.
I think your component will come in handy though because it gives me an idea of how to create my own components for things like this so thanks again.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Delphi
--
Questions
--
Followers
Top Experts
Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.