我有一个TAction,它同时用于菜单项和TButton。我希望菜单项显示标签,TButton只显示图标。但是,当一个Action被分配时,Vcl会自动设置TButton的标题属性,而我无法摆脱它。
有什么想法吗?
发布于 2012-12-11 09:02:15
在菜单项上,将ImageIndex设置为-1。在按钮上,将Caption设置为''。您必须在运行时执行此操作。
这将破坏与仅针对这些单独属性的操作的关联。该动作仍将用于Hint、OnExecute、OnUpdate等。
发布于 2012-12-11 09:39:36
您可以有两个单独的操作:一个用于菜单项,一个用于按钮。
发布于 2012-12-11 09:33:20
一个更麻烦的解决方案可能是将标记22设置为例如,在下面的示例中
type
TButton=Class(Vcl.StdCtrls.TButton)
procedure SetText(var Message:TWMSETTEXT); message WM_SETTEXT;
End;
TForm4 = class(TForm)
ActionList1: TActionList;
ImageList1: TImageList;
Action1: TAction;
BitBtn1: TBitBtn;
Button1: TButton;
Button2: TButton;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
{ TMyButton }
procedure TButton.SetText(var Message:TWMSETTEXT);
begin
if Tag<>22 then inherited else Message.Result := 1;
end;https://stackoverflow.com/questions/13816394
复制相似问题