Skip to content

ModernUI_TrayMenu Control

mrfearless edited this page Oct 24, 2018 · 3 revisions

TrayMenu Functions

MUITrayMenuRegister

Description: Registers the main ModernUI_TrayMenu class. Use 'ModernUI_TrayMenu' as class in RadASM custom class control.

Parameters: None

MUITrayMenuCreate

Description: Creates a new ModernUI_TrayMenu control. Returns in rax the handle of the control if successfully created.

Parameters: hWndParent, hTrayMenuIcon, lpszTooltip, qwMenuType, qwMenu, qwOptions, hWndExtra

MUITrayMenuSetProperty

Description: Sets a specified property of the ModernUI_TrayMenu control with a value.

Parameters: hModernUI_TrayMenu, qwProperty, qwPropertyValue

MUITrayMenuGetProperty

Description: Retrieves the value of a specified ModernUI_TrayMenu control property.

Parameters: hModernUI_TrayMenu, qwProperty

MUITrayMenuAssignMenu

Description: Assigns a previously created menu handle to the ModernUI_TrayMenu control.

Parameters: hModernUI_TrayMenu, qwMenuType, qwMenu

MUITrayMenuSetTrayIcon

Description: Sets the icon for the ModernUI_TrayMenu control. This icon shows in the notification system tray.

Parameters: hModernUI_TrayMenu, hTrayIcon

MUITrayMenuSetTooltipText

Description: Sets the tooltip text for the TrayMenu icon in the notification system tray.

Parameters: hModernUI_TrayMenu, lpszTooltip

MUITrayMenuEnableMenuItem

Description: Enables a menu item.

Parameters: hModernUI_TrayMenu, MenuItemID

MUITrayMenuDisableMenuItem

Description: Disabled a menu item.

Parameters: hModernUI_TrayMenu, MenuItemID

MUITrayMenuChangeMenuItemState

Description: Changes menu item state.

Parameters: hModernUI_TrayMenu, MenuItemID, MenuItemState

MUITrayMenuSetMenuItemText

Description: Sets/changes the text for the menu item.

Parameters: hModernUI_TrayMenu, MenuItemID, lpszMenuItemText

MUITrayMenuHideTrayIcon

Description: Hide tray icon.

Parameters: hModernUI_TrayMenu

MUITrayMenuShowTrayIcon

Description: Show tray icon.

Parameters: hModernUI_TrayMenu

MUITrayMenuShowNotification

Description: Show a notification tip over the tray icon with a message.

Parameters: hModernUI_TrayMenu, lpszNotificationMessage, lpszNotificationTitle, qwTimeout, qwStyle

MUITrayMenuSetTrayIconText

Description: Creates a transparent icon with text. Useful for percentages, degrees or other text information.

Parameters: hModernUI_TrayIcon, lpszText, lpszFont, qwTextColorRGB

Tray Icon Functions (standalone - no menu):

MUITrayIconCreate

Description: Create a standalone tray icon without a menu.

Parameters: hWndParent, qwTrayIconResID, hTrayIcon, lpszTooltip - Returns in rax hModernUI_TrayIcon

MUITrayIconDestroy

Description: Destroys a standalone tray icon

Parameters: hModernUI_TrayIcon

MUITrayIconSetTrayIcon

Description: Sets/changes the standalone tray icon.

Parameters: hModernUI_TrayIcon, hTrayIcon

MUITrayIconSetTooltipText

Description: Sets/changes the tooltip text of a standalone tray icon.

Parameters: hModernUI_TrayIcon, lpszTooltip

MUITrayIconShowNotification

Description: Notification with a message to show over the standalone tray icon.

Parameters: hModernUI_TrayIcon, lpszNotificationMessage, lpszNotificationTitle, qwTimeout, qwStyle

TrayMenu Styles

The TrayMenu control supports a number of style flags (defined in the .inc include file) that allow you to customize the behaviour of the control.

Tray Menu Type: Used with theqwMenuType parameter of the TrayMenuCreate and TrayMenuAssignMenu functions

  • MUITMT_MENUDEFER - Specifies that the qwMenu parameter of is TrayMenuCreate and TrayMenuAssignMenu functions is ignored. Typically used to defer the attachment of a menu till later after the control has been created.
  • MUITMT_POPUPMENU - Specifies that the qwMenu parameter is a handle to a menu created with a call to CreatePopupMenu.
  • MUITMT_MENUITEMS - Specifies that the qwMenu parameter is a pointer to a list of MUITMITEM structures used to build a menu from. Thel macros: MUITRAYMENU, MUITRAYMENU_ITEM and MUITRAYMENU_END are provided for ease of creating a menu using this MUITMITEM structure.
  • MUITMT_NOMENUEVER - Specifies that no menu is ever added to the icon at any point.

Tray Menu Style: Used with the qwStyle parameter of the TrayMenuCreate function

  • MUITMS_DEFAULT - Default style
  • MUITMS_MINONCLOSE - Minimizes parent window when close clicked
  • MUITMS_HIDEIFMIN - Hide parent window when minimized
  • MUITMS_HWNDEXTRA - Use the hWndExtra parameter of the TrayMenuCreate function or the @TrayMenuExtraWndHandle property for the handle to use as the window to process for hiding/showing, instead of the default parent window to the TrayMenu control..

Tray Menu Notification Icon: Used with the qwStyle of the MUITrayIconShowNotification function

  • MUITMNI_NONE - No icon.
  • MUITMNI_INFO - An information icon.
  • MUITMNI_WARNING - A warning icon.
  • MUITMNI_ERROR - An error icon.

TrayMenu Properties

  • @TrayMenuIcon - hIcon to display in tray
  • @TrayMenuTooltipText - lpszText to display over icon in tray
  • @TrayMenuVisible - bool visible = TRUE/FALSE
  • @TrayMenuType - Tray Menu Type: MUITMT_MENUDEFER, MUITMT_POPUPMENU, MUITMT_MENUITEMS, or MUITMT_NOMENUEVER
  • @TrayMenuHandleMenu - hMenu
  • @TrayMenuExtraWndHandle - hWnd extra window handle to use for restoring a main window that isnt parent to current child window that TrayMenu is based on.

TrayMenu Macros

The macros are an optional way of constructing a menu. At runtime the menu is created by looping through the data structure and creating the menu items based on the supplied data of the MUITMITEM structure. The start and end of the structure, as defined by the label used to represent this, are marked with special characters to recognize the start and end of this data block. The MenuType parameter of the TrayMenuCreate and TrayMenuAssignMenu functions has to be set to MUITMT_MENUITEMS if using these macros.

  • MUITRAYMENU - Begins tray menu definition. Requires a parameter for the Tray Menu label.
  • MUITRAYMENU_ITEM - Adds a row of data representing a MUITMITEM structure. Parameters required for Menu Text, Menu Resource ID, Menu State. Menu State can be ENABLED or DISABLED. Menu Text set to begin with a dash '-' is seen as a menu separator, other parameters for menu separator are not required.
  • MUITRAYMENU_END - Ends the tray menu definition.

Example:

.CONST
IDM_TEST0               EQU 10007
IDM_TEST1               EQU 10008
IDM_TRAY_URL            EQU 10009
IDM_TRAY_EXIT           EQU 10010
IDM_TRAY_OPT            EQU 10011

.DATA
szTrayMenuTooltip       DB 'ModernUI TrayMenu',0
szTest0                 DB "TrayMenu Control",0
szTest1                 DB "fearless 2016",0
szWebUrl                DB "www.LetTheLight.in",0
szOptions               DB "Options...",0
szTrayMenuExit          DB "Exit",0

; TrayMenu macros used to define a menu for use with the TrayMenu control
;
;                      Menu Text Var      Menu ID        Menu State Notes
;                      __________________ ______________ __________ ______
MUITRAYMENU TrayMenu1
    MUITRAYMENU_ITEM   szTest0,           IDM_TEST0,     ENABLED    ; Test 0
    MUITRAYMENU_ITEM   -----------------                            ; Seperator
    MUITRAYMENU_ITEM   szTest1,           IDM_TEST1,     ENABLED    ; Test 1
    MUITRAYMENU_ITEM   szWebUrl,          IDM_TRAY_URL,  ENABLED    ; Url
    MUITRAYMENU_ITEM   -----------------                            ; Seperator
    MUITRAYMENU_ITEM   szOptions,         IDM_TRAY_OPT,  ENABLED    ; Options
    MUITRAYMENU_ITEM   -----------------                            ; Seperator
    MUITRAYMENU_ITEM   szTrayMenuExit,    IDM_TRAY_EXIT, ENABLED    ; Exit 
MUITRAYMENU_END

.DATA?
hIcoMain                DQ ?
hTrayMenu               DQ ?

.CODE
; Create our ModernUI_TrayMenu control
Invoke MUITrayMenuCreate, hWin, hIcoMain, Addr szTrayMenuTooltip, MUITMT_MENUITEMS, Addr TrayMenu1, MUITMS_MINONCLOSE or MUITMS_HIDEIFMIN, NULL
mov hTrayMenu, rax