ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Menu functions
  • Associating an image with a menu option
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
MenuAddOption (Function)
In french: MenuAjouteOption
AjaxNot available
Adds a new option after the last option of a drop-down or context menu. This menu option executes a WLanguage procedure. To insert a menu option at a specific location, use MenuInsertOption.
Reminder: The name of the main menu is defined:
  • WINDEV in the description window of the window.
  • WEBDEV - Server code in the description window of the menu.
Example
WINDEV
// Adds a new menu to MENU_MyMenu
MenuAddMenu(MENU_MyMenu, "OPT_Schedule", "Schedule")
// Adds an option to the new OPT_Schedule menu
MenuAddOption("OPT_Schedule", "OPT_Create", "Create", Create_Schedule)
// Associates an image with the OPT_Create menu option
{"OPT_Create", indControl}..Image = "schedule.png"
// Add a separator
MenuAddSeparator("OPT_Schedule")
// Adds a new option (OPT_View)
MenuAddOption("OPT_Schedule", "OPT_View", "View", View_schedule)
Syntax
<Result> = MenuAddOption(<Source menu> , <Option to create> , <Caption> , <WLanguage procedure> [, <Procedure parameter>])
<Result>: Integer
Position of the option in the menu. If the option is not added, a fatal error occurs.
<Source menu>: Menu name
Name of the menu to which the menu option should be added. The option will be added after the last option in this menu.
Remark: This name can correspond to a context menu.
PHP Context menus are not available.
<Option to create>: Character string
Name of the menu option to add. This name will be used to programmatically handle the menu option.
If there is an option with the same name, a fatal error occurs.
<Caption>: Character string
Text of the new menu option. This text will be displayed in the window and will allow users to select the option.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure called when the menu option is selected.
WEBDEV - Server code This procedure must be a server procedure.
<Procedure parameter>: Optional variant
Parameter that can be passed to <WLanguage procedure> when the menu option is selected by the user.
Remarks

Associating an image with a menu option

To associate an image with a menu option, use the Image property.
Related Examples:
WD LastDocuments Sample components (WINDEV): WD LastDocuments
[ + ] This example explains how the list of last opened documents can be added to the application menu.
This insertion is performed via a class proposed in the "LastDocuments" component.
Four code lines are sufficient to insert the list of last opened documents into an existing application.
These processes can be found in:
- the declaration code of the global variables of the main window,
- the code of the OpenDocument procedure,
- the code of the menu options "File 1" to "File 10".
The example has been simplified regarding the number of features (text files only) in order to highlight the use of the component.
Component: wd290obj.dll
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/05/2024

Send a report | Local help