2012-10-25 143 views
2

显示提示我奋力大大试图让在TActionMainMenuBar显示提示。德尔福XE2。德尔福XE2 TActionMainMenubar

我在运行时创建菜单。我添加类别,子项目,清除菜单,这一切都很好。点击菜单项可以正常工作(现在它只是执行带有操作项标签的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; 

我设置的动作提示”我也尝试用分配OnHint事件,但OnHint事件永远不会被调用我简单。在那个提示浏览菜单时,无法得到。

我ShowHint设置为true,我到处都可以看到的地方去做。

的问题是,我不能让任何菜单提示显示,不管我怎么努力。如果我可以得到它,我可以显示它我自己(如果程序不会)。 OnHint永远不会被调用。

我已经发布我的菜单程序(德尔福XE2)的全部源代码,一个小例子缩小为尽我所能,在如果任何人希望看到的节目我公开的DropBox。

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

+1

你预计要显示的提示?菜单项不会获得工具提示。 –

+0

要显示菜单项的提示,你需要一个'TStatusBar'添加到您的形式,并设置它的'AutoHint'属性为TRUE;。正如@Rob所说,菜单项不会得到弹出式工具提示。 –

+0

感谢您的反馈。我在过去的我能够用TMainMenu时访问菜单提示进行TMenuItems,我可以在弹出窗口中显示出来,但对于actionmenu项目提示我还是不能去。通过试验和错误,我现在可以获得类别操作(菜单标题)的提示,但不会显示子菜单操作提示。我认为这是好消息,因为这意味着至少在这些类别中有提示。再次感谢您的帮助。 – mthand

回答

0

这不正是你想要什么:www.delphi.about.com/od/vclusing/a/menuitemhints.htm

它处理WM_MENUSELECT消息,并显示在自己的窗口提示(TMenuItemHint = class(THintWindow))。