Solved

EASY - Popup menu in VB6

Posted on 2002-07-01
6
548 Views
Last Modified: 2010-05-02
Hello everyone. I'm sure this must be an easy one.

I want to create a popup menu, on the right mouse click on a form.

I have looked in the help file and it tells me to create a popup menu using the menu editor. I have tried this, but it just creates a menu at the top of the form (or actually at the top of the main form as I am developing an MDI app).

What must I do to create a popup menu, that does not appear as a regular menu?

Thanks
0
Comment
Question by:DapperDan
  • 2
  • 2
  • 2
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7121733
You have to create the menu as normal menu and hide it (set visible of the main part to invisible. The name of the top menu could be for example mnuPopMyForm, and below (indended) the menu items you want to see when using the popup.

Then, on MouseUp of the Form, use this code:
PopupMenu mnuPopMyForm
Using the other parameters of this function, you will be able to influence the position and the behaviour, but the above is the least you need to do

CHeers

0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7121747
-Try this

As you have created the menu in the menu editor. Set its property to Visible=false ie the uncheck the visible property of the main menu

Suppose you have the foll
-Options (id-mnuOptions)
--File (id-mnuFile)
--Open (id mnuOpen)

and then write this...

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

PopupMenu mnuoptions

End Sub
------------------------------

Hope this helps

-priya


0
 

Author Comment

by:DapperDan
ID: 7121784
Thanks, to both of you.

I think you basically said the same thing. It's working now but I have one problem.

As I said earlier, this is an MDI app. Now when I click on a particular subform, it hides the main application menus, and replaces it with an empty menu (as the subform has no visible menus).

Is there a way of stopping the subform from replacing the main application menus? I suppose I could put the same menus into the subform, but this seems a bit sloppy.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 150 total points
ID: 7121815
In VB, this is unfortunately not possible unless you move the menus for the mdi Child forms into an activeX-control which you place onto the form and where you can negociate the menus places.
CHeers
0
 

Author Comment

by:DapperDan
ID: 7121833
OK, thanks. Using ActiveX seems a bit excessive here (:

I'll just have to duplicate the menus.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7122631
oops, late posting..sorry DapperDan! I  think when I was writing the suggestion, something came up. So when I completed it later(ie after 7 minutes), a similar suggestion was aleady posted.

No probs, Hope you could find a solution to your problem. That's important.

-Priya

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now