- What is Windows context menu and how to configure it
- WM_CONTEXTMENU message
- Parameters
- Return value
- Remarks
- Меню и контекстные меню Menus and context menus
- Выбор правильного элемента управления Is this the right control?
- MenuBar и MenuFlyout MenuBar vs. MenuFlyout
- MenuBar и CommandBar MenuBar vs. CommandBar
- Примеры Examples
- Сравнение меню и контекстных меню Menus vs. context menus
- Меню Menus
- Контекстные меню Context menus
- Значки Icons
- Создание всплывающего или контекстного меню Create a menu flyout or a context menu
- Исчезновение Light dismiss
- Создание строки меню Create a menu bar
What is Windows context menu and how to configure it
Many people like Windows operating system, and many of us grew up on it. But some fickle PC users – or those who recently switched to Windows – often confused in search of information about some simple things that run the operating system from Microsoft. One of such elements a graphic element is called the «Windows context menu» or «menu right mouse button».
Today we will tell you not only about this integral element of interaction with Windows, but third-party app that allows you to add custom items in the context menu.
So what is Windows context menu?
In simple words, this pop-up menu that appears when clicking right mouse button in any navigation area of the screen (hence the name «menu with the right mouse button»). Access context menu, you can get folders in the task bar, in web browsers and other areas of the graphical interface. The context menu is not an exclusive feature of Windows, so you could see it in other operating systems, including Mac OS X or Linux.
Speaking about the appearance of the context menu of Windows, then everywhere it looks almost identical – differ only in the elements inside of it. For example, the screenshot below shows the context menu that opens when you click the right mouse button on the desktop, for example, to set a background image of the desktop in the Personalization window.
Usually the shortcut menu carries such items as «View», «Sort», «Copy», «Paste», «Rename», «Properties», etc. Some of the menu items based on context. In other words, in one of the areas of the operating system context menu may contain some items and the other has other. For example, the menu that POPs up when you right-click on the taskbar, will contain completely different items compared to the menu that you see in the screenshot below.
Here is another simple example of the context menu that appears when you right-click on the folder:
Now that you know what is context menu in Windows, and how it works, let us consider a convenient and free app with which you can easily customize the menu.
Context Menu Tuner
A portable application with Context Menu Tuner that allows you to add custom items in menu «right mouse button» in Windows 7, Windows 8 and Windows 8.1, was developed by Sergey Tkachenko (WinAero) – known developer who is the author of many useful tools, including TakeOwnershipEx. The app is very convenient in the sense that the whole process of adding items to the context menu requires the user a few taps.
To begin, launch the application. Interface Context Menu Tuner consists of two different panes – the left contains a list of supported commands, and the right is from Windows Explorer. To add a command, you need to choose one of them in the left pane, and then, after selecting your preferred item in the right pane, click on the «Add» button. For the removal of the added commands, as you can guess, answers the «Delete»button.
Additional app features allow you to add delimiters before and after certain menu items. In addition, there are a couple of options.
Another interesting feature of the app is its ability to add custom commands to certain file types. Open the window «Select file type», which can be accessed by clicking on the button «Add -> Add the specified type of file» in the main application window, you will see an impressive number of supported file extensions. The list is very long, so to quickly find a specific file type, use search engine.
The screenshot below shows my context menu that I changed with Context Menu Tuner:
That’s about it. Now you know what is a Windows context menu, and know a simple solution for editing.
WM_CONTEXTMENU message
Notifies a window that the user desires a context menu to appear. The user may have clicked the right mouse button (right-clicked) in the window, pressed Shift+F10 or pressed the applications key (context menu key) available on some keyboards.
Parameters
A handle to the window in which the user right-clicked the mouse. This can be a child window of the window receiving the message. For more information about processing this message, see the Remarks section.
The low-order word specifies the horizontal position of the cursor, in screen coordinates, at the time of the mouse click.
The high-order word specifies the vertical position of the cursor, in screen coordinates, at the time of the mouse click.
Return value
No return value.
Remarks
A window can process this message by displaying a shortcut menu using the TrackPopupMenu or TrackPopupMenuEx functions. To obtain the horizontal and vertical positions, use the following code.
If a window does not display a shortcut menu it should pass this message to the DefWindowProc function. If a window is a child window, DefWindowProc sends the message to the parent. Otherwise, DefWindowProc displays a default shortcut menu if the specified position is in the window’s caption.
DefWindowProc generates the WM_CONTEXTMENU message when it processes the WM_RBUTTONUP or WM_NCRBUTTONUP message or when the user types SHIFT+F10. The WM_CONTEXTMENU message is also generated when the user presses and releases the VK_APPS key.
If the context menu is generated from the keyboard for example, if the user types SHIFT+F10 then the x- and y-coordinates are -1 and the application should display the context menu at the location of the current selection rather than at (xPos, yPos).
Меню и контекстные меню Menus and context menus
В меню и контекстных меню отображается список команд или параметров, когда пользователь запрашивает их. Menus and context menus display a list of commands or options when the user requests them. Для отображения отдельного встроенного меню используйте всплывающее меню. Use a menu flyout to show a single, inline menu. Используйте строку меню, чтобы отобразить набор меню в горизонтальной строке, обычно в верхней части окна приложения. Use a menu bar to show a set of menus in a horizontal row, typically at the top of an app window. Каждое меню может включать пункты меню и вложенные меню. Each menu can have menu items and sub-menus.
Получение библиотеки пользовательского интерфейса Windows Get the Windows UI Library
Элемент управления MenuBar является частью библиотеки пользовательского интерфейса Windows — пакета NuGet, который содержит новые элементы управления и компоненты пользовательского интерфейса для приложений для Windows. The MenuBar control is included as part of the Windows UI Library, a NuGet package that contains new controls and UI features for Windows apps. Дополнительные сведения, включая инструкции по установке, см. в обзорной статье о библиотеке пользовательского интерфейса Windows. For more info, including installation instructions, see the Windows UI Library overview.
API-интерфейсы библиотеки пользовательского интерфейса Windows: Класс MenuBar Windows UI Library APIs: MenuBar class
Выбор правильного элемента управления Is this the right control?
Меню и контекстные меню экономят место, упорядочивая команды и скрывая их до востребования. Menus and context menus save space by organizing commands and hiding them until the user needs them. Если определенная команда используется часто, и имеется достаточно свободного места, вы можете разместить ее на отдельном элементе, а не в меню, чтобы для ее использования пользователям не приходилось открывать меню. If a particular command will be used frequently and you have the space available, consider placing it directly in its own element, rather than in a menu, so that users don’t have to go through a menu to get to it.
Меню и контекстные меню предназначены для упорядочения команд. Для отображения произвольного содержимого, например уведомлений или запросов подтверждения, используйте диалоговые окна и всплывающие элементы. Menus and context menus are for organizing commands; to display arbitrary content, such as a notification or confirmation request, use a dialog or a flyout.
MenuBar и MenuFlyout MenuBar vs. MenuFlyout
Чтобы отобразить меню во всплывающем окне, присоединенном к элементу пользовательского интерфейса на холсте, используйте элемент управления MenuFlyout для размещения пунктов меню. To show a menu in a flyout attached to an on-canvas UI element, use the MenuFlyout control to host your menu items. Вы можете вызывать всплывающее меню как обычное меню или контекстное меню. You can invoke a menu flyout either as a regular menu or as a context menu. Всплывающее меню содержит единое меню верхнего уровня и вложенные меню (необязательно). A menu flyout hosts a single top-level menu (and optional sub-menus).
Строка меню (MenuBar) позволяет отображать набор из нескольких меню верхнего уровня в горизонтальной строке. To show a set of multiple top-level menus in a horizontal row, use a menu bar. Строка меню обычно размещается в верхней части окна приложения. You typically position the menu bar at the top of the app window.
MenuBar и CommandBar MenuBar vs. CommandBar
MenuBar и CommandBar представляют области, которые можно использовать для отображения команд пользователям. MenuBar and CommandBar both represent surfaces that you can use to expose commands to your users. MenuBar обеспечивает простой и быстрый способ выводить набор команд в приложениях, которым могут понадобиться дополнительные функции упорядочения или группирования, недоступные в CommandBar. The MenuBar provides a quick and simple way to expose a set of commands for apps that might need more organization or grouping than a CommandBar allows.
MenuBar также можно использовать в сочетании с CommandBar. You can also use a MenuBar in conjunction with a CommandBar. MenuBar позволяет отобразить все команды, а CommandBar — выделить наиболее часто используемые команды. Use the MenuBar to provide the bulk of the commands, and the CommandBar to highlight the most used commands.
Примеры Examples
XAML Controls Gallery XAML Controls Gallery |
---|