|
|
|
|
|
|
Basic How To |
|
How To Add a PopUp Menu |
|
Download VB Sample |
|
Return to main How To Page |
Adding a PopUp Menu to ALLText
Open the VB Menu Editor, now fill in the Caption and Name fields. Next un-check the visible attribute and click the next button.
Now click the Right Arrow to move the selected menu down one level. Notice that the visible attribute is checked, leave it this way and fill in the Caption and Name fields. Repeat this process until you have completed you menu and click OK to exit the Menu Editor.
Open the ALLText MouseDown Event and place the code that traps the right mouse button. See the below screen shot.
You can now right click within ALLText and generate a PopUp Menu.
|
MouseDown and MouseUp Events |
Description: Occur when the user presses (MouseDown) or releases (MouseUp) a mouse button while over the ALLText control.
Syntax:
Sub ATX_MouseDown ([Index%,]Button As Integer, Shift As Integer, X As Single, Y As Single)
Sub ATX_MouseUp ([Index %,]Button As Integer, Shift As Integer, X As Single, Y As Single)
Parameters: The MouseDown event uses these arguments:
Argument |
Description |
Index |
Uniquely identifies a control if it is in a control array. |
Button |
The button which triggered the event. This is a bit flag value. If a bit is set it indicates that the button was down.
1 - LEFT_BUTTON
2 - RIGHT_BUTTON
4 - MIDDLE_BUTTON |
Shift |
This is a bit flag indicating the state of the Shift, Ctrl and Alt keys. The bit is set if the key is down. The following BitMasks may be used
1 - SHIFT_MASK
2 - CTRL_MASK
4 - ALT_MASK |
X ,Y |
The current location of the mouse pointer. X and Y are always expressed in terms of the coordinate system set by the ScaleHeight, Scale Width, ScaleLeft, and ScaleTop properties of the object. |
|
Visual Basic PopupMenu Method |
Description: Displays a pop-up menu on an MDIForm or Form object at the current mouse location or at specified coordinates. Doesn't supportnamed arguments.
Syntax: object.PopupMenu menuname, flags, x, y, boldcommand
The PopupMenu method syntax has these parts:
Part |
Description |
object |
Optional. Anobject expression that evaluates to an object in the Applies To list. If object is omitted, the form with thefocus is assumed to be object. |
Menuname |
Required. The name of the pop-up menu to be displayed. The specified menu must have at least one submenu. |
Flags |
Optional. A value or constant that specifies the location and behavior of a pop-up menu, as described in Settings. |
X |
Optional. Specifies the x-coordinate where the pop-up menu is displayed. If omitted, the mouse coordinate is used. |
Y |
Optional. Specifies the y-coordinate where the pop-up menu is displayed. If omitted, the mouse coordinate is used. |
boldcommand |
Optional. Specifies the name of a menu control in the pop-up menu to display its caption in bold text. If omitted, no controls in the pop-up menu appear in bold. |
Settings:
The settings for flags are:
Constant (location) |
Value |
Description |
vbPopupMenuLeftAlign |
0 |
(Default) The left side of the pop-up menu is located at x. |
vbPopupMenuCenterAlign |
4 |
The pop-up menu is centered at x. |
vbPopupMenuRightAlign |
8 |
The right side of the pop-up menu is located at x. |
Constant (location) |
Value |
Description |
vbPopupMenuLeftButton |
0 |
(Default) An item on the pop-up menu reacts to a mouse click only when you use the left mouse button. |
vbPopupMenuRightButton |
2 |
An item on the pop-up menu reacts to a mouse click when you use either the right or the left mouse button. |
Remarks: These constants are listed in the Visual Basic (VB)object library in theObject Browser.
You specify the unit of measure for the x and y coordinates using the ScaleMode property. The x and y coordinates define where the pop-up is displayed relative to the specified form. If the x and y coordinates aren't included, the pop-up menu is displayed at the current location of the mouse pointer.
When you display a pop-up menu, the code following the call to the PopupMenu method isn't executed until the user either chooses a command from the menu (in which case the code for that command's Click event is executed before the code following the PopupMenu statement) or cancels the menu. In addition, only one pop-up menu can be displayed at a time; therefore, calls to this method are ignored if a pop-up menu is already displayed or if a pull-down menu is open.
|