在Delphi XE2的TActionMainMenuBar中显示提示信息

3
我正在努力让提示在TActionMainMenuBar中显示,这涉及编程相关内容。我正在使用Delphi XE2。我正在运行时创建菜单,并添加类别和子项,清除菜单也都很顺利。点击菜单项可以正常工作(目前它只是使用操作项目标签显示ShowMessage,但这没问题)。以下是添加新菜单项的代码:
function TActionF.NewAction(AParent: TActionClientItem; Caption: String; aTag : integer; ExecuteAction: TNotifyEvent):TActionClientItem;
var
  newActionClient : TActionClientItem;
  AnewAction : TAction;
begin
  newActionClient := TActionClientItem(AParent.Items.insert(AParent.Items.Count));
  newActionClient.Caption := Caption; //??
  newActionClient.UsageCount := -1; // turn of menu priority stuff for now
  AnewAction := TAction.Create(Self);
  AnewAction.Tag := aTag;
  AnewAction.ImageIndex := -1;
  AnewAction.Caption := Caption;
  AnewAction.Hint := Caption + 'Action Tag = ' + IntToStr(aTag);
  AnewAction.OnHint := acnDoHint;  // fixed, could be parameter, but onHint is never called    !!??
  AnewAction.OnExecute := ExecuteAction; // passed as parameter
  newActionClient.Action := AnewAction;
  Result := newActionClient;
end;

我正在设置操作的提示"Hint"。 我也尝试过分配OnHint,但是OnHint从未被调用过。在浏览菜单时,我根本无法获取那个提示。我已经在所有可以看到的地方将ShowHint设置为True。问题是无论我尝试什么,都无法显示任何菜单提示。如果我能找到它,我可以自己显示它(如果程序不行)。OnHint从未被调用过。如果有人想查看程序,在我的公共DropBox中发布了我完整的菜单程序源代码(Delphi XE2),这是一个尽量缩小的小例子。

https://dl.dropbox.com/u/58421925/Actions.zip


1
你希望提示显示在哪里?菜单项不会显示工具提示。 - Rob Kennedy
要为菜单项显示提示,您需要向窗体添加一个 TStatusBar,并将其 AutoHint 属性设置为 True。正如 @Rob 所说,菜单项不会弹出工具提示。 - Ken White
感谢您的反馈。以前我在使用TMainMenu时能够访问TMenuItems的菜单提示,并且可以在弹出窗口中显示它们,但是我仍然无法获取actionmenu项的提示。通过试错,我现在可以获取类别操作(菜单标题)的提示,但不能获取子菜单操作项的提示。这对我来说是好消息,因为至少意味着提示存在于类别中。再次感谢您的帮助。 - mthand
1个回答

0
这会完全满足你的需求:www.delphi.about.com/od/vclusing/a/menuitemhints.htm
它处理WM_MENUSELECT消息,并在自己的窗口中显示提示(TMenuItemHint = class(THintWindow))。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接