Link to home
Start Free TrialLog in
Avatar of jgore
jgore

asked on

show control on Pop-Up Menu

How do I show a control on Pop-Up Menu?

I know how to make a popup menu but I need a control or two
on it. Like maybe a combobox, or perhaps labels to click, or???
I'm tired of just having text on popup menus.

This will be used on a richtextbox sitting on a SSTab.
I can easily bring up the menu with a right click.
How do I add controls?    (no ocx's please).
Avatar of AzraSound
AzraSound
Flag of United States of America image

Avatar of Marine
Marine

it would take subclassing to do this and probably a lot of it to get this done.
The following code would be used to display the Format menu when the user clicks the right mouse button on any open area of the form:

Private Sub Lable1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
    Me.PopupMenu popFormat
End If
End Sub


Place the code for the PopupMenu method in the MouseDown or MouseUp(((((typically the MouseUp))))) event of the form.

pop-up menu named popFormat

Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
    Me.PopupMenu popFormat
End If
End Sub
if you are ready for some hard work - build you own menu.
it can be made on any container that you can place controls on (picBox, form,frame). prepare it as you need - and "popup" it in the right location and time.
Avatar of jgore

ASKER

To AzraSound:
I don't want to show a menu for a  button.
I wan't to put a control on a menu.

To Ruchi:
I don't get it. How is that going to put a control on a menu? Looks like your just calling up a menu. I can do
that. I just can't call one up with a combo box or something on it.

To AnswerTheMan:
I would love to do that. I even started to do it.
But, I can't make the second form (my container, hadn't thought of using a pic box or frame) show up where the mouse is!  I tried all kinds of things!

Private Sub richtext1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

If Button And vbRightButton Then
   Form2.Top = y
   Form2.Left = x
   Form2.Show    ' Show PopUp Menu
End If
End sub

heh, that doesn't work!
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
naturally there may be more events that need to set the frame's visible property to false in the case the user doesnt click back into your richtextbox.
Avatar of jgore

ASKER

That works for me!
I was using a second form but I like frame much better. This way focus stays on  form1.
After looking at your example I don't know why
I didn't figure it out in a second! hehe
Thanks again!