PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Tips and tricks
  • Replacing the caption of a menu option by the content of a control
  • Adding help to a menu option
  • Customizing the appearance of a menu
  • Making the main menu of a window invisible
  • Running code before displaying the popup menu
  • Displaying a popup menu via a left click
  • Dissociating a popup menu from a control or from a window
  • Retrieving the number of the table row and column onto which a right click is performed
  • Changing the popup menu according to the element selected in a TreeView control
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
This page presents some operations specific to the menus and to the menu options:
Notes:
Versions 21 and later
WINDEVWINDEV MobileUniversal Windows 10 App This feature is now available in Universal Windows 10 App mode.
New in version 21
WINDEVWINDEV MobileUniversal Windows 10 App This feature is now available in Universal Windows 10 App mode.
WINDEVWINDEV MobileUniversal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Tips and tricks

Replacing the caption of a menu option by the content of a control

You must:
  • retrieve the content of the control.
  • modify the caption of the menu option with ..Caption or with MenuLabel.
Examples:
  • The caption of "MyOption" must correspond to the value entered in "MyControl".
    MyOption..Caption = MyControl
    // Equivalent to: MenuLabel(MyOption, MyControl)
  • The caption of "MyOption" must correspond to the content of the cell belonging to "COL_MyColumn" and to the row selected by the user in the Table control named "TABLE_MyTable":
    MyOption..Caption = COL_MyColumn[TableSelect(TABLE_MyTable)]
    // Equivalent to:
    // MenuLabel(MyOption, COL_MyColumn[TableSelect(TABLE_MyTable)])

Adding help to a menu option

To explain the operating mode of how each menu option, a help message can be displayed in the status bar of the window when an option is highlighted.
How to proceed?
This help message is entered in the "Help" tab of the description window of the menu options ("Option description" from the popup menu). This help message can be multilingual.
Note: This help message can be modified by programming with the Message function or with the ..Message property.

Customizing the appearance of a menu

To customize the appearance of a menu, all you have to do is customize the style of an option in this menu. These modifications will be automatically applied to all the menu options.
You have the ability to customize:
  • the background color of a menu.
  • the font (size, color, ...) of the menu options.
  • the background color of the hovered option.
  • the font (size, color, ...) of the option hovered by the mouse cursor.
To customize the appearance of a menu:
  1. Select a menu option.
  2. Display the "Style" tab in the description window of the menu options ("Option description" from the popup).
  3. To customize:
    • the background color or the menu: select "Option background" in the "Element" combo box and select the background color of the option.
    • the font for the menu options: select "Option text" in the "Element" combo box and select the characteristics of the font (attributes, size, color, ...)
    • the background color of the hovered option: select "Option background (rollover)" in the "Element" combo box and select the background color of the option hovered by the mouse cursor.
Note: The background color or the text color can be:
  • a preset color. Select this color among the ones proposed in the "Color" combo box.
  • a custom color. Define this color with the color picker ("..." button on the right of the "Color" combo box).
For example:
Background color of options and text color
Special case: Menu in XP style
Only the characteristics of the font defined for the menu options will be taken into account if the menu is using the XP style. See Using the XP style in your windows for more details.
Universal Windows 10 App You cannot customize the appearance of a menu.

Making the main menu of a window invisible

To make the main menu invisible, all you have to do is make all the "main" options of the menu invisible.
Example: The "main" options of the following menu are "Files" and "Prints".
=Main options
To make this main menu invisible, enter the following code:
// Make the "Files" and "Prints" options invisible
Files..Visible = False
Prints..Visible = False
// Equivalent to:
// MenuInvisible(Files)
// MenuInvisible(Prints)

Running code before displaying the popup menu

To run code before displaying the popup menu, all you have to do is add the optional process named "Display popup menu" into the code of the element (control or window) associated with the popup menu.
How to proceed?
  1. Display the code of the element (control or window) associated with the popup menu ("Code" from the popup menu of the element).
  2. Click the "..." icon found in the icon bar of the code window. The list of optional processes found in the code is displayed.
    Bar of optional processes
  3. Check the optional "Displaying popup menu" process.
  4. In this optional process, enter the code that will be run before displaying the popup menu.

Displaying a popup menu via a left click

To display a popup menu via a left click, all you have to do simulate the action of a right click in the optional process named "Left button down" of an element (control or window).
In order for the popup menu to be displayed during a left click (and not during a right click), the element (control or window) must not be associated by default with a popup menu.
Example: The operations required to display a popup menu when left-clicking are illustrated in the following example: The popup menu named "MyMenu" is automatically displayed when a left click is performed on the edit control named "MyControl".
  1. Display the code of "MyControl" ("Code" from the popup menu of the control).
  2. Add the optional "Left button down" process (click the second icon found in the icon bar of the code window).
    =Bar of optional processes
  3. In this optional process, enter the following code lines:
// Associate the popup menu with the control
MyControl..PopupMenu = MyMenu
// Simulate a right click on the button to call
// the popup menu
SendMessage(Handle(MySelf), 516, 0, 0)
SendMessage(Handle(MySelf), 517, 0, 0)
// Dissociate the popup menu from the control
MyControl..PopupMenu = ""

Dissociating a popup menu from a control or from a window

To dissociate a popup menu from a control or a window, use ..PopupMenu and pass an empty character string ("") in parameter.
Example
// Dissociate the popup menu from the control
MyControl..PopupMenu = ""
Note: If a system popup menu is available, this popup menu will replace the custom popup menu.

Retrieving the number of the table row and column onto which a right click is performed

To retrieve the number of the table row and column selected by a right click before displaying the popup menu, use TableInfoXY in the optional "Right button down" process.
Example: The operations required to retrieve the number of the row and column selected by a right mouse click are illustrated in the following example: The popup menu "MyMenu" is associated with the Table control named "TABLE_MyTable". This menu is used to handle the content of the cell from which the popup menu is opened.
The selected cell is colored in blue before displaying the popup menu.
  1. Display the code of "TABLE_MyTable" ("Code" from the popup menu of the control).
  1. Add the optional "Left button down" process (click the Optional process icon icon found in the icon bar of the code window).
    Bar of optional processes
  1. In this optional process, enter the following code lines:
// Retrieve the row and column selected via a right click
NumSelectedRow, NumSelectedCol are int
NumSelectedRow = TableInfoXY (MySelf, tiLineNumber, MouseXPos(), MouseYPos())
NumSelectedCol = TableInfoXY (MySelf, tiColNumber, MouseXPos(), MouseYPos())
// Modify the color of the selected cell
TABLE_MyTable [NumSelectedRow][NumSelectedCol]..BrushColor = LightBlue
WINDEV

Changing the popup menu according to the element selected in a TreeView control

To dynamically change the popup menu when selecting an element in a TreeView control, use ..PopupMenu. This property must be used when the right click is intercepted on the TreeView control (optional "Right click" process).
Example: The operations required to dynamically change a popup menu when right-clicking an element of a TreeView are illustrated in the following example:
The following popup menus are associated with the "TREE_Groups" control:
  • ctxUser: used to handle the users listed in the TreeView control.
  • ctxGroup: used to handle the groups of users listed in the TreeView control.
    Each treeview node represents a group of users. Each treeview leaf represents a user.
  1. Display the code of "TREE_Groups" ("Code" from the popup menu of the control).
  1. Position your cursor in the optional "Right click of TREE_Groups" process .
  1. In this process, enter the following code lines:
// -- Right click of TREE_Groups
// According to the type of the element selected in the treeview,
// the popup menu to display is changed
nElementType = TreeTypeItem(TREE_Groups, TreeSelect(TREE_Groups))

SWITCH nElementType
CASE tvLeaf // It's a user
TREE_Groups..PopupMenu = ctxUser
CASE tvNode // It's a group of users
TREE_Groups..PopupMenu = ctxGroup
OTHER CASE // If an error occurs
TREE_Groups..PopupMenu = ""
END
Result:
First popup menu of an elementSecond popup menu of an element
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment