Reputation: 438
I have some issues with a TToolButton in Delphi XE4.
procedure TForm2.FormCreate(Sender: TObject);
begin
btn1.Style := tbsDropDown;
btn1.DropDownMenu := pmCreateReport1;
btn1.PopupMenu := pmCreateReport1;
FDown := True;
btn1.down := FDown;
end;
procedure TForm2.btn1Click(Sender: TObject);
begin
FDown := not FDown;
btn1.down := FDown;
end;
After FormCreate the down property is set to true and it works, but when I click the button the down property is not working as expected. After the second click on the button the button should be down again.
The debugger says that the property is set to true, which is correct, but I cannot see it on the form.
When I am using a simple TToolButton without the style tbsdropdown its working as expected.
Do you have any ideas?
Upvotes: 0
Views: 936
Reputation: 11
For me, the following worked in said button's OnClick
event:
ToolBar.Perform(TB_PRESSBUTTON, ToolButton.Index, 1);
TB_PRESSBUTTON
is defined in CommCtrl
as WM_USER + 3
, or 1027. Make sure to not set your tool button's Down
property to True. Setting Down
to False still works normally.
Upvotes: 1
Reputation: 1
Use ActionList
, set AutoCheck property True,
sample code:
const
wm_tlbtnShowClosedClicked = WM_USER + 100;
TForm2 = class(TForm)
.....
private
procedure tlbtnShowClosedClicked(var Msg :TMessage); message wm_tlbtnShowClosedClicked;
end
procedure TForm2.tlbtnShowClosedClicked(var Msg: TMessage);
begin
btn1.Down := (btn1.Action as TAction).Checked;
end;
Upvotes: 0
Reputation: 163347
The documentation explains it:
Tool buttons can remain Down only if
Style
istbsCheck
.
You'll have to find some other way of achieving the representation you want.
Upvotes: 2