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 clcik 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..
good luck
walther
Return