Process Hacker
emenu.c File Reference
#include <phgui.h>
#include <emenu.h>

Go to the source code of this file.

Functions

PPH_EMENU_ITEM PhAllocateEMenuItem (VOID)
 
PPH_EMENU_ITEM PhCreateEMenuItem (_In_ ULONG Flags, _In_ ULONG Id, _In_ PWSTR Text, _In_opt_ HBITMAP Bitmap, _In_opt_ PVOID Context)
 Creates a menu item.
 
VOID PhpDestroyEMenuItem (_In_ PPH_EMENU_ITEM Item)
 Frees resources used by a menu item and its children.
 
VOID PhDestroyEMenuItem (_In_ PPH_EMENU_ITEM Item)
 Frees resources used by a menu item and its children.
 
PPH_EMENU_ITEM PhFindEMenuItem (_In_ PPH_EMENU_ITEM Item, _In_ ULONG Flags, _In_opt_ PWSTR Text, _In_opt_ ULONG Id)
 Finds a child menu item.
 
PPH_EMENU_ITEM PhFindEMenuItemEx (_In_ PPH_EMENU_ITEM Item, _In_ ULONG Flags, _In_opt_ PWSTR Text, _In_opt_ ULONG Id, _Out_opt_ PPH_EMENU_ITEM *FoundParent, _Out_opt_ PULONG FoundIndex)
 Finds a child menu item.
 
ULONG PhIndexOfEMenuItem (_In_ PPH_EMENU_ITEM Parent, _In_ PPH_EMENU_ITEM Item)
 Determines the index of a menu item.
 
VOID PhInsertEMenuItem (_Inout_ PPH_EMENU_ITEM Parent, _Inout_ PPH_EMENU_ITEM Item, _In_ ULONG Index)
 Inserts a menu item into a parent menu item.
 
BOOLEAN PhRemoveEMenuItem (_Inout_opt_ PPH_EMENU_ITEM Parent, _In_opt_ PPH_EMENU_ITEM Item, _In_opt_ ULONG Index)
 Removes a menu item from its parent.
 
VOID PhRemoveAllEMenuItems (_Inout_ PPH_EMENU_ITEM Parent)
 Removes all children from a menu item.
 
PPH_EMENU PhCreateEMenu (VOID)
 Creates a root menu.
 
VOID PhDestroyEMenu (_In_ PPH_EMENU Menu)
 Frees resources used by a root menu and its children.
 
VOID PhInitializeEMenuData (_Out_ PPH_EMENU_DATA Data)
 Initializes a data structure containing additional information resulting from a call to PhEMenuToHMenu().
 
VOID PhDeleteEMenuData (_Inout_ PPH_EMENU_DATA Data)
 Frees resources used by a data structure initialized by PhInitializeEMenuData().
 
HMENU PhEMenuToHMenu (_In_ PPH_EMENU_ITEM Menu, _In_ ULONG Flags, _Inout_opt_ PPH_EMENU_DATA Data)
 Converts an EMENU to a Windows menu object.
 
VOID PhEMenuToHMenu2 (_In_ HMENU MenuHandle, _In_ PPH_EMENU_ITEM Menu, _In_ ULONG Flags, _Inout_opt_ PPH_EMENU_DATA Data)
 Converts an EMENU to a Windows menu object.
 
VOID PhHMenuToEMenuItem (_Inout_ PPH_EMENU_ITEM MenuItem, _In_ HMENU MenuHandle)
 Converts a Windows menu object to an EMENU.
 
VOID PhLoadResourceEMenuItem (_Inout_ PPH_EMENU_ITEM MenuItem, _In_ HINSTANCE InstanceHandle, _In_ PWSTR Resource, _In_ ULONG SubMenuIndex)
 Loads a menu resource and converts it to an EMENU.
 
PPH_EMENU_ITEM PhShowEMenu (_In_ PPH_EMENU Menu, _In_ HWND WindowHandle, _In_ ULONG Flags, _In_ ULONG Align, _In_ ULONG X, _In_ ULONG Y)
 Displays a menu.
 
BOOLEAN PhSetFlagsEMenuItem (_Inout_ PPH_EMENU_ITEM Item, _In_ ULONG Id, _In_ ULONG Mask, _In_ ULONG Value)
 Sets the flags of a menu item.
 
VOID PhSetFlagsAllEMenuItems (_In_ PPH_EMENU_ITEM Item, _In_ ULONG Mask, _In_ ULONG Value)
 Sets flags for all children of a menu item.
 
VOID PhModifyEMenuItem (_Inout_ PPH_EMENU_ITEM Item, _In_ ULONG ModifyFlags, _In_ ULONG OwnedFlags, _In_opt_ PWSTR Text, _In_opt_ HBITMAP Bitmap)
 

Function Documentation

PPH_EMENU_ITEM PhAllocateEMenuItem ( VOID  )

Definition at line 41 of file emenu.c.

PPH_EMENU PhCreateEMenu ( VOID  )

Creates a root menu.

Definition at line 404 of file emenu.c.

PPH_EMENU_ITEM PhCreateEMenuItem ( _In_ ULONG  Flags,
_In_ ULONG  Id,
_In_ PWSTR  Text,
_In_opt_ HBITMAP  Bitmap,
_In_opt_ PVOID  Context 
)

Creates a menu item.

Parameters
FlagsA combination of the following:
  • PH_EMENU_DISABLED The menu item is greyed and cannot be selected.
  • PH_EMENU_CHECKED A check mark is displayed.
  • PH_EMENU_HIGHLIGHT The menu item is highlighted.
  • PH_EMENU_MENUBARBREAK Places the menu item in a new column, separated by a vertical line.
  • PH_EMENU_MENUBREAK Places the menu item in a new column, with no vertical line.
  • PH_EMENU_DEFAULT The menu item is displayed as the default item. This causes the text to be bolded.
  • PH_EMENU_RADIOCHECK Uses a radio-button mark instead of a check mark.
IdA unique identifier for the menu item.
TextThe text displayed for the menu item.
BitmapA bitmap image for the menu item.
ContextA user-defined value.

Definition at line 72 of file emenu.c.

VOID PhDeleteEMenuData ( _Inout_ PPH_EMENU_DATA  Data)

Frees resources used by a data structure initialized by PhInitializeEMenuData().

Definition at line 452 of file emenu.c.

VOID PhDestroyEMenu ( _In_ PPH_EMENU  Menu)

Frees resources used by a root menu and its children.

Parameters
MenuA root menu.

Definition at line 422 of file emenu.c.

VOID PhDestroyEMenuItem ( _In_ PPH_EMENU_ITEM  Item)

Frees resources used by a menu item and its children.

Parameters
ItemThe menu item.
Remarks
The menu item is automatically removed from its parent.

Definition at line 136 of file emenu.c.

HMENU PhEMenuToHMenu ( _In_ PPH_EMENU_ITEM  Menu,
_In_ ULONG  Flags,
_Inout_opt_ PPH_EMENU_DATA  Data 
)

Converts an EMENU to a Windows menu object.

Parameters
MenuThe menu item to convert.
FlagsA combination of the following:
  • PH_EMENU_CONVERT_ID Automatically assigns a unique identifier to each converted menu item. The resulting mappings are placed in Data.
DataAdditional data resulting from the conversion. The data structure must be initialized by PhInitializeEMenuData() prior to calling this function.
Returns
A menu handle. The menu object must be destroyed using DestroyMenu() when it is no longer needed.

Definition at line 474 of file emenu.c.

VOID PhEMenuToHMenu2 ( _In_ HMENU  MenuHandle,
_In_ PPH_EMENU_ITEM  Menu,
_In_ ULONG  Flags,
_Inout_opt_ PPH_EMENU_DATA  Data 
)

Converts an EMENU to a Windows menu object.

Parameters
MenuHandleA handle to a Windows menu object.
MenuThe menu item to convert. The items are appended to MenuHandle.
FlagsA combination of the following:
  • PH_EMENU_CONVERT_ID Automatically assigns a unique identifier to each converted menu item. The resulting mappings are placed in Data.
DataAdditional data resulting from the conversion. The data structure must be initialized by PhInitializeEMenuData() prior to calling this function.

Definition at line 517 of file emenu.c.

PPH_EMENU_ITEM PhFindEMenuItem ( _In_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Flags,
_In_opt_ PWSTR  Text,
_In_opt_ ULONG  Id 
)

Finds a child menu item.

Parameters
ItemThe parent menu item.
FlagsA combination of the following:
  • PH_EMENU_FIND_DESCEND Searches recursively within child menu items.
  • PH_EMENU_FIND_STARTSWITH Performs a partial text search instead of an exact search.
  • PH_EMENU_FIND_LITERAL Performs a literal search instead of ignoring prefix characters (ampersands).
TextThe text of the menu item to find. If NULL, the text is ignored.
IdThe identifier of the menu item to find. If 0, the identifier is ignored.
Returns
The found menu item, or NULL if the menu item could not be found.

Definition at line 166 of file emenu.c.

PPH_EMENU_ITEM PhFindEMenuItemEx ( _In_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Flags,
_In_opt_ PWSTR  Text,
_In_opt_ ULONG  Id,
_Out_opt_ PPH_EMENU_ITEM FoundParent,
_Out_opt_ PULONG  FoundIndex 
)

Finds a child menu item.

Parameters
ItemThe parent menu item.
FlagsA combination of the following:
  • PH_EMENU_FIND_DESCEND Searches recursively within child menu items.
  • PH_EMENU_FIND_STARTSWITH Performs a partial text search instead of an exact search.
  • PH_EMENU_FIND_LITERAL Performs a literal search instead of ignoring prefix characters (ampersands).
TextThe text of the menu item to find. If NULL, the text is ignored.
IdThe identifier of the menu item to find. If 0, the identifier is ignored.
FoundParentA variable which receives the parent of the found menu item.
FoundIndexA variable which receives the index of the found menu item.
Returns
The found menu item, or NULL if the menu item could not be found.

Definition at line 199 of file emenu.c.

VOID PhHMenuToEMenuItem ( _Inout_ PPH_EMENU_ITEM  MenuItem,
_In_ HMENU  MenuHandle 
)

Converts a Windows menu object to an EMENU.

Parameters
MenuItemThe menu item in which the converted menu items will be placed.
MenuHandleA menu handle.

Definition at line 622 of file emenu.c.

ULONG PhIndexOfEMenuItem ( _In_ PPH_EMENU_ITEM  Parent,
_In_ PPH_EMENU_ITEM  Item 
)

Determines the index of a menu item.

Parameters
ParentThe parent menu item.
ItemThe child menu item.
Returns
The index of the menu item, or -1 if the menu item was not found in the parent menu item.

Definition at line 292 of file emenu.c.

VOID PhInitializeEMenuData ( _Out_ PPH_EMENU_DATA  Data)

Initializes a data structure containing additional information resulting from a call to PhEMenuToHMenu().

Definition at line 441 of file emenu.c.

VOID PhInsertEMenuItem ( _Inout_ PPH_EMENU_ITEM  Parent,
_Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Index 
)

Inserts a menu item into a parent menu item.

Parameters
ParentThe parent menu item.
ItemThe menu item to insert.
IndexThe index at which to insert the menu item. If the index is too large, the menu item is inserted at the last position.

Definition at line 312 of file emenu.c.

VOID PhLoadResourceEMenuItem ( _Inout_ PPH_EMENU_ITEM  MenuItem,
_In_ HINSTANCE  InstanceHandle,
_In_ PWSTR  Resource,
_In_ ULONG  SubMenuIndex 
)

Loads a menu resource and converts it to an EMENU.

Parameters
MenuItemThe menu item in which the converted menu items will be placed.
InstanceHandleThe module containing the menu resource.
ResourceThe resource identifier.
SubMenuIndexThe index of the sub menu to use, or -1 to use the root menu.

Definition at line 690 of file emenu.c.

VOID PhModifyEMenuItem ( _Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  ModifyFlags,
_In_ ULONG  OwnedFlags,
_In_opt_ PWSTR  Text,
_In_opt_ HBITMAP  Bitmap 
)

Definition at line 855 of file emenu.c.

VOID PhpDestroyEMenuItem ( _In_ PPH_EMENU_ITEM  Item)

Frees resources used by a menu item and its children.

Parameters
ItemThe menu item.
Remarks
The menu item is NOT automatically removed from its parent. It is safe to call this function while enumerating menu items.

Definition at line 102 of file emenu.c.

VOID PhRemoveAllEMenuItems ( _Inout_ PPH_EMENU_ITEM  Parent)

Removes all children from a menu item.

Parameters
ParentThe parent menu item.

Definition at line 384 of file emenu.c.

BOOLEAN PhRemoveEMenuItem ( _Inout_opt_ PPH_EMENU_ITEM  Parent,
_In_opt_ PPH_EMENU_ITEM  Item,
_In_opt_ ULONG  Index 
)

Removes a menu item from its parent.

Parameters
ParentThe parent menu item. If Item is NULL, this parameter must be specified.
ItemThe child menu item. This may be NULL if Index is specified.
IndexThe index of the menu item to remove. If Item is specified, this parameter is ignored.

Definition at line 346 of file emenu.c.

VOID PhSetFlagsAllEMenuItems ( _In_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Mask,
_In_ ULONG  Value 
)

Sets flags for all children of a menu item.

Parameters
ItemThe parent menu item.
MaskThe flags to modify.
ValueThe new value of the flags.

Definition at line 838 of file emenu.c.

BOOLEAN PhSetFlagsEMenuItem ( _Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Id,
_In_ ULONG  Mask,
_In_ ULONG  Value 
)

Sets the flags of a menu item.

Parameters
ItemThe parent menu item.
IdThe identifier of the child menu item.
MaskThe flags to modify.
ValueThe new value of the flags.

Definition at line 807 of file emenu.c.

PPH_EMENU_ITEM PhShowEMenu ( _In_ PPH_EMENU  Menu,
_In_ HWND  WindowHandle,
_In_ ULONG  Flags,
_In_ ULONG  Align,
_In_ ULONG  X,
_In_ ULONG  Y 
)

Displays a menu.

Parameters
MenuA menu.
WindowHandleThe window that owns the popup menu.
FlagsA combination of the following:
  • PH_EMENU_SHOW_SEND_COMMAND A WM_COMMAND message is sent to the window when the user clicks on a menu item.
  • PH_EMENU_SHOW_LEFTRIGHT The user can select menu items with both the left and right mouse buttons.
AlignThe alignment of the menu.
XThe horizontal location of the menu.
YThe vertical location of the menu.
Returns
The selected menu item, or NULL if the menu was cancelled.

Definition at line 728 of file emenu.c.