Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Associating an image with a menu option
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
<Menu>.AddOption (Function)
In french: <Menu>.AjouteOption
AjaxNot available
Adds a new menu option at the end of a menu. This menu option runs a procedure passed as parameter. To insert a menu option at a specific location, use <Menu>.InsertOption.
Reminder: The name of the main menu is defined:
    // Ajoute un nouveau menu
    MENU_MonMenu.AjouteMenu("OPT_Planning", "Planning")
    // Ajoute une option dans le nouveau menu
    OPT_Planning.AjouteOption("OPT_Créer", "Créer", Créer_Planning)
    // Associe une image à l'option de menu
    {"OPT_Créer", indControl}..Image = "planning.png"
    // Ajoute un séparateur
    // Ajoute une nouvelle option
    OPT_Planning.AjouteOption("OPT_Voir", "Voir", Voir_planning)
    <Result> = <Source menu>.AddOption(<Option to create> , <Libellé> , <WLanguage procedure> [, <Procedure parameter>])
    <Result>: entier
    Position of the option in the menu. A fatal error occurs if the option was not added.
    <Source menu>: Menu name
    Name of the menu into which the menu option must be added. The menu option will be added at the end of this menu.
    <Option to create>: Character string
    Name of the menu option to add. This name will be used to handle the menu option through programming.
    A fatal error occurs if this name corresponds to an existing option.
    <Libellé>: Character string
    Caption of the new menu option. This caption will be displayed in the window and it will allow the user to select the option.
    <WLanguage procedure>: Procedure name
    Name of the WLanguage procedure called when the menu option is selected.
    <Procedure parameter>: Optional variant
    Parameter that can be passed to <WLanguage procedure> when the menu option is selected by the user.

    Associating an image with a menu option

    To associate an image with a menu option, use Image.
    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: wd270obj.dll
    Minimum version required
    • Version 23
    This page is also available for…
    Click [Add] to post a comment