Hi,
How do I make a menu popup from a CommandButton?
I want the code to popup a menu on a CommandButton & it has OK button on it.
Regards!
Hi,
How do I make a menu popup from a CommandButton?
I want the code to popup a menu on a CommandButton & it has OK button on it.
Regards!
Pop-ups
According to the Microsoft’s terminology, the term “pop-up” can be used for several controls: pop-up menu, pop-up button, and submenu. With Add-in Express you can create your own pop-up as an element of your controls commandbar collection and add to it any control via the Controls property. But pop-ups have a feature that is very annoying: if an edit box or a combo box is added to a pop-up, their events are fired very oddly. Don’t regard this bug as that of Add-in Express. It seems to be intended by Microsoft.
You can remove the "vbExclamation +", or replace it with vbCritical, vbQuestion... Just select one from the list you get when writing down ur code.Code:MsgBox "Your Message", vbExclamation + vbOKOnly, "Box Title"
Making & using a PopUp Menu
Making a popup menu (vb4)
step 1: starting
step 2: make the menu-options
step 3: make the code
step 4: let the popup appears
step 5: running....
step 1: starting
make a new project; a new form; some labels with caption; some textboxes
and some commandbuttons
step 2: make the menu-options
- view the form
- choose Tools/Menu Editor
- make a option:
caption = Testing
name = dummy
visible = FALSE
- make some sub-options:
caption = &Clear
name = testing
index = 1
caption = &Print
name = testing
index = 2
- click on OKE
step 3: make the code
- view code of the form
- choose for Object = testing
- place the next code:
Select case Index
Case 1 'clear
Call ClearAll
Case 2 'print
PrintForm
End Select
in the general section place the next proc:
Private sub ClearAll()
Dim Control
For Each Control In Form1.Controls
If TypeOf Control Is TextBox Then Control.Text = ""
If TypeOf Control Is Label Then Control.Caption = ""
If TypeOf Control Is CommandButton Then Control.Caption = ""
Next Control
End Sub
step 4: let the popup appears
- place in the MouseDown event of every control you want to accept
a request for the popup to show the next code
Private sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If button = 2 Then Me.PopupMenu dummy
End Sub
step 5: press F5 and click the right button on different locations on the form.
Of course it's just an example. You can let different popupmenus appear with different
controls. All with different options. It's just for the idea..
If you have added a menu using the form's menu editor, then you can make a popup menu by using:
Form1.PopUpMenu menuheadername
Bookmarks