?
Solved

VB6 popup (contect menu)

Posted on 2004-07-30
15
Medium Priority
?
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 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