[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 548
  • Last Modified:

VB6 popup (contect menu)

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
djguvnor
Asked:
djguvnor
  • 4
  • 3
  • 2
  • +4
1 Solution
 
AnnamalaiSwamyCommented:
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
 
djguvnorAuthor Commented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
djguvnorAuthor Commented:
"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
 
kurian2z5Commented:
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
 
djguvnorAuthor Commented:
Do you think it makes any difference that I'm doing it on an ActiveX control and not a form?
0
 
kurian2z5Commented:
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
 
djguvnorAuthor Commented:
how do I do that?
0
 
kurian2z5Commented:
i dont really know bout activex controls. other experts any help ?
0
 
AnnamalaiSwamyCommented:
There is no explicit properties to be set for displaying popup from activex control.
0
 
KarcOriginCommented:
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
 
MuertyCommented:
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
 
moduloCommented:
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.

  • 4
  • 3
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now