View Full Version : How to change order of ToolButtons
mangos
05-02-2005, 10:16 PM
Hello,
How to change order of ToolButtons in ToolBar?
Property Index is readonly.
Thanks
mangos
Norrit
05-02-2005, 10:36 PM
Hi ...
procedure TForm1.Button1Click(Sender: TObject);
procedure SetButtonIndex(Button: Integer; Value: Integer);
var
Positions : array of Integer;
ButtonID : Integer;
i,
CurrentID : integer;
begin
CurrentID := ToolBar1.Buttons[Button].Index;
SetLength(Positions, 0);
for ButtonID := 0 to ToolBar1.ButtonCount - 1
do begin
if ToolBar1.Buttons[ButtonID].Index >= Length(Positions)
then SetLength(Positions, ToolBar1.Buttons[ButtonID].Index + 1);
Positions[ToolBar1.Buttons[ButtonID].Index] := ButtonID;
end;
if (CurrentID <> Value) and
(CurrentID >- 1) and
(Value >-1 ) and
(Value<Length(Positions))
then begin
if Value < CurrentID
then begin
for i := Value to CurrentID - 1
do ToolBar1.Buttons[Button].Left := -1;
end
else if Value > CurrentID
then begin
for i := CurrentID + 1 to Value
do ToolBar1.Buttons[Positions].Left := -1;
end;
end;
end;
begin
SetButtonIndex(1, 0);
end;
MvG
Peter
[i]Objective reality is a delirium caused by lack of alcohol in blood.
24 hous in a day, 24 beers in a case. Coincidence ???
There are 10 kinds of people: Those who understand binary and those who don't
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.