Solved

VB6 popup (contect menu)

Posted on 2004-07-30
15
472 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:djguvnor
Comment Utility
"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
Comment Utility
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
Comment Utility
Do you think it makes any difference that I'm doing it on an ActiveX control and not a form?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:kurian2z5
Comment Utility
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
Comment Utility
how do I do that?
0
 
LVL 4

Expert Comment

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

Expert Comment

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

Expert Comment

by:KarcOrigin
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with no points refunded (of 150)

modulo
Community Support Moderator
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Controlling which port to download from 4 57
DIR issue 7 45
Problem to skip loop 6 48
How does CurrentUser work? 10 25
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

728 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

14 Experts available now in Live!

Get 1:1 Help Now