问题描述
首先,让我说我在Windows Vista和Windows 7中取消了此功能.第二,我想这样做. 此处是一个问题,问如何在WPF中做我想做的事情.
First, let me say that I abominate this feature in Windows Vista and Windows 7. Second, I want to do it. Here is a question asking how to do what I want here, in WPF.
我想做同样的事情,但是在Delphi中,使用VCL库存组件,TMainMenu或Action Manager菜单,或一些可用的第三方组件,甚至Toolbar2000或某些其他库.
I want to do the same thing, but in Delp using VCL stock components, TMainMenu or Action Manager menus, or some available third party components, even Toolbar2000 or some other library.
Windows Vista/Windows 7资源管理器主菜单的功能:
Feature of Windows Vista/Windows 7 explorer main-menus:
- 应用启动时不可见
- 按下并释放Alt使其可见
- 再次按下并释放Alt使其再次不可见
- 可重复.
- 即使菜单不可见,热键也可用于菜单项*
(* Windows资源管理器热键示例:即使菜单不可见,Microsoft Windows资源管理器中的Ctrl + A也会选择全部,Alt + T =弹出工具弹出菜单,即使整个菜单都隐藏了.)
(* Windows Explorer Hotkeys Example: Ctrl+A in Microsoft Windows Explorer selects all even when the menus are invisible, Alt+T = bring up Tools popup menu, even when the whole menu is hidden).
更新:可以下载使用接受的答案的演示此处. (HiddenMenu.zip)
Update: Demo using accepted answer can be downloaded here. (HiddenMenu.zip)
推荐答案
照常使用TMainMenu
和TActionList
.
然后做
procedure TForm1.FormShow(Sender: TObject);
begin
Self.Menu := nil;
end;
(或仅在设计时删除Menu
关联)和
(or simply remove the Menu
association at design time) and
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_MENU) or (Key = VK_F10) then
Menu := MainMenu1;
end;
和
procedure TForm1.WndProc(var Message: TMessage);
begin
inherited;
case Message.Msg of
WM_EXITMENULOOP:
SetMenu(Handle, 0);
end;
end;
别忘了将表单的KeyPreview
设置为true
.
Don't forget to set the form's KeyPreview
to true
.
(请注意,由于快捷方式是由TActionList
处理的,因此即使菜单为消失"也可以使用.)
(Notice that, since the shortcuts are handled by the TActionList
, they work even if the menu is 'gone'.)
这篇关于Delphi程序中的隐藏主菜单,使用Alt键自动显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!