|
- Overview
- Tips and tricks
- Replacing the caption of a menu option by the control content
- Adding help to a menu option
- Customizing the menu appearance
- 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 on which a right click is performed
- Changing the popup menu according to the element selected in a TreeView control
Menus and menu options: Tips & Tricks
This page presents some operations specific to the menus and to the menu options: Remarks: - For more details about the menus and menu options, see:
- All these "Tips & Tricks" can be used with the main menus and with the popup menus unless stated otherwise.
Versions 21 and later New in version 21 Replacing the caption of a menu option by the control content All you have to do is: - retrieve the control content.
- modify the caption of menu option with ..Caption or with MenuLabel.
Examples: - The caption of "MyOption" must correspond to the value typed 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 each menu option, a help message can be displayed in the status bar of window when an option is highlighted. How to do This help message is typed in the "Help" tab of the description window of menu options ("Option description" from the popup menu). This help message can be multilingual. Remark: This help message can be modified by programming with the Message function or with the ..Message property. Customizing the menu appearance To customize the menu appearance, all you have to do is customize the style of an option in this menu. These modifications will be automatically applied to all menu options. You can customize: - the background color of a menu.
- the font (size, color, ...) of menu options.
- the background color of hovered option.
- the font (size, color, ...) of the option hovered by the mouse cursor.
To customize the menu appearance: - Select a menu option.
- Display the "Style" tab in the description window of menu options ("Option description" from the popup).
- To customize:
- the background color of menu: select "Option background" in the "Element" combo box and select the background color of the option.
- the font of menu options: select "Option text" in the "Element" combo box and select the font characteristics (attributes, size, color, ...)
- the background color of hovered option: select "Option background (rollover)" in the "Element" combo box and select the background color of the option hovered by the mouse cursor.
Remark: 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 "Color" combo box).
Special case: Menu in XP styleOnly 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. Making the main menu of a window invisible To make the main menu invisible, all you have to do is make all "main" options of the menu invisible. Example: The "main" options of the following menu are "Files" and "Prints".
Pto make Invisible this main menu, 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, simply add the optional event named "Display popup menu" into the code of the element (control or window) associated with the popup menu. How to do it? - Display the code of the element (control or window) associated with the popup menu ("Code" from the popup menu of element).
- Click the link "Add other events to xxx" at the bottom of the window code, after the last event.
- In the list of optional events, select "Displaying popup menu" and validate.
- In this optional event, write 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, simply simulate the action of a right click in the optional event 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". - Display the code of "MyControl" ("Code" from the popup menu of control).
- Click on the link "Add more events to xxx" located at the end of the code window, after the last event. In the HEX@ of optional events, select the event "Left button pressed" and validate.
- In this optional event, write the following code:
// 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 = ""
Remark: 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 on 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 event "Right button down". 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. - Display the code of "TABLE_MyTable" ("Code" from the popup menu of control).
- Click on the link "Add more events to xxx" located at the end of the code window, after the last event. In the HEX@ of optional events, select the event "Right button pressed" and validate.
- In this optional event, write the following code:
// 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
This page is also available for…
|
|
|
| |
| Click [Add] to post a comment |
|
| |
|
| |
| |
| |
| |
| |
| |
| | |
| |