But first identifying the tab, this can be done in the OnRulerItemSelect of the ruler.
Some helper functions...
Code: Select all
function InRange(pos, min, max, tol: Integer): Boolean;
begin
Result := True;
if (min - pos) > tol then Result := False;
if (pos - max) > tol then Result := False;
end;
function NearBy(pos, tar, tol: Integer): Boolean;
begin
Result := InRange(pos, tar, tar, tol);
end;
Code: Select all
type
TForm1 = class(TForm)
private
FTabNr: Integer;
// ...
procedure TForm1.rulHorizontalRulerItemSelect(Sender: TObject; X: Integer);
var
I: Integer;
begin
FTabNr := -1;
for I := 0 to rulHorizontal.Tabs.Count - 1 do
if NearBy(rulHorizontal.Tabs[I].Left, X, 4) then
FTabNr := I;
end;
Code: Select all
procedure TForm1.rulHorizontalDblClick(Sender: TObject);
begin
if FTabNr >= 0 then
if rulHorizontal.Tabs[FTabNr].Align = taLeftAlign then
rulHorizontal.Tabs[FTabNr].Align := taRightAlign
else
rulHorizontal.Tabs[FTabNr].Align := taLeftAlign;
end;
Code: Select all
// Ruler.pas
procedure TCustomRuler.MouseDown(...);
// ...
if (Button = mbLeft) and not (ssDouble in Shift) then
// ...
end;
Pieter