Solved

VB6 popup (contect menu)

Posted on 2004-07-30
15
498 Views
Last Modified: 2013-12-25
I've followed the code in this example:  http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20942908.html  but still cannot get my menu to work.

I'm creating an ActiveX control in VB6 and created a menu using the menu editor that looks like this:

Pop
....Move Up
....Move Down

with names nodemenu, nodemenuup and nodemenudown respectively.

Then in my code I have the following relevent bits:

Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
        popupmenu nodemenu
    End If
End Sub

When I run it and right click on the control I get the error:  428 popup menu must have at least one submenu

I tried creating this on a seperate form and that didn't seem to have any effect.

Any ideas?

For bonus points how do I then assign code to the menu click events?
0
Comment
Question by:djguvnor
  • 4
  • 3
  • 2
  • +4
15 Comments
 
LVL 2

Expert Comment

by:AnnamalaiSwamy
ID: 11675524
For Run time "428 popup menu must have at least one submenu"

In order to display popup menu all your menus should be child menu.

Top level menus cannot be displayed with popup.

eg.,
Pop
....Move Up
....Move Down

in above code you can display move up and move down menus by calling  "Popupmenu pop". Same way "nodemenu" should have some child menus to display them in the popup menu.

For each Child menus add in the menu editor , the associated click events will be shown in the code pane where you can implement.

Click events will not be avaliable for top level menus.

Hope it helps.

Thanks.

0
 
LVL 1

Author Comment

by:djguvnor
ID: 11676394
I don't understand,  my top level menu item is:
Caption: Pop
Name: nodemenu

It has 2 children
Caption: Move Up
Name: nodemenuup

and

Caption: Move Down
Name: nodemenudown

So when I call:
popupmenu nodemenu
surely that is calling a menu with 2 submenus?

I'm obviously missing something fundamental here!  All I want is a popup menu with Move Up and Move Down on it!
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11683790
It sounds like you haven't actually got your submenu items indented properly, so VB doesn't think they are actually child items.

As far as handling the click events for each menu goes. Each menu item is available like any other control.  If you click the left-hand combo box at the top of the VB editor window, each of you menu items should be listed. Just select the one you're interested in and it should create the outline for you. Something like:

    Private Sub mnunodeup_Click()
        '// Code to run when menu item clicked
    End Sub


Hope this helps.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:djguvnor
ID: 11691539
"It sounds like you haven't actually got your submenu items indented properly"

They look like child items.  How else do you add child items?  There's no 'add child item' button in fact the user interface of the menu editor doesn't make a whole lot of sense but either way my menu still doesn't work and now this is getting silly.  Someone must know how to do this?
0
 
LVL 4

Expert Comment

by:kurian2z5
ID: 11691599
try
me.popupmenu nodemenu

maybe they shud be hidden first.

i dont know whats wrong, i created the menus u made and it works fine.
0
 
LVL 1

Author Comment

by:djguvnor
ID: 11691608
Do you think it makes any difference that I'm doing it on an ActiveX control and not a form?
0
 
LVL 4

Expert Comment

by:kurian2z5
ID: 11691780
oh i forgot. it is because of that. ull have to set properties and stuff to make the popup appear when the activex control is placed on a form.
0
 
LVL 1

Author Comment

by:djguvnor
ID: 11691801
how do I do that?
0
 
LVL 4

Expert Comment

by:kurian2z5
ID: 11691820
i dont really know bout activex controls. other experts any help ?
0
 
LVL 2

Expert Comment

by:AnnamalaiSwamy
ID: 11692524
There is no explicit properties to be set for displaying popup from activex control.
0
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 12062055
Try these steps and tell me if you still get the same error -
How to add menu -
1. Open your activeX control and goto Tools -> Menu Editor.

2. Add new items lets say
File (name: mnuFile)
Now click the Next button and then click arrow which is indicating to Right (->)
Add subitem lets say New (name: mnuName)
Now again click the Next button and then again click arrow which is indicating to Right (->)
Add subitem lets say Close (name: mnuClose)

3. Now select File from the list that is displayed on the same dislog box and set Visible to false by make it unchecked.

By doing this you are having one Menu item (File) and two subitems (New and Close)

Now test your ActiveX control on the test project. Rest is the same as you were doing before.
0
 
LVL 3

Expert Comment

by:Muerty
ID: 12447951
The entire problem is likely because you did not specify the index data for the child popup menus....

In the menu editor, select your popup menu, ensure that the index for the popup menu title is not set, then foro each child item make sure you set each one to a numeric value .. in your case 1 and 2

Make sure they are marked as visible while the top level menu is not marked as visible.

To easily make the menu items code wrapper for your code, simply turn on visibility for the menu, view the control in the IDE and select the menu item, the code window should open and allow you to complete the code as needed. Repeat for the other menu item.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12942300
PAQed with no points refunded (of 150)

modulo
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

726 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