Solved

Adding a new menu-point to a pop-up menu

Posted on 2000-04-17
4
160 Views
Last Modified: 2010-05-02
Is it possible to add a completely new menu point to a pop-up menu during
runtime in Visual Basic??? This points shouldn´t appear in the same menu
but in a menu-point below. E.g:

Option Explicit

Private Sub Form_Load()
Dim i
  For i = 1 To 4
    Load Sub1(i)
    Sub1(i).Caption = "Hello" + Str$(i)
  Next
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 2 Then
    If Shift = 2 Then  'Ctrl
      PopupMenu Menu
    Else
      PopupMenu Menu1
    End If
  End If
End Sub
 

This is not what i want the menu to do. This code doesn´t create a new
menu-point. I don´t know if it is possible do crack this nut in VB.....
Please give me an answere.

0
Comment
Question by:_alpha
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2723167
If Sub1(0) is a submenu of Menu or Menu1, it should work fine.  Not sure what you mean by "menu-point."

Menu1 'Main level
 - Sub1(0) ' Sub menu item

Then the code works fine.
0
 

Expert Comment

by:Jalen
ID: 2723382
Well, If its to add items to the menu, use the api call here,
Declare Function InsertMenuItem& Lib "user32" Alias "InsertMenuItemA" (ByVal _
hMenu As Long, ByVal un As Long, ByVal bypos As Long, lpcMenuItemInfo As _
MENUITEMINFO)

The parameters are described as follows:
hMenu      Long—Handle of a menu.
un      Long—The menu ID or position of a menu entry. The new entry is inserted before the item specified by this parameter.
bypos      Long—True if un specifies the position of the entry, False if it is a menu ID.
lpMenuItemInfo      MENUITEMINFO—A MENUITEMINFO structure to use to set the characteristics of the specified menu entry.
0
 

Accepted Solution

by:
Jalen earned 200 total points
ID: 2723385
Well, If its to add items to the menu, use the api call here,
Declare Function InsertMenuItem& Lib "user32" Alias "InsertMenuItemA" (ByVal _
hMenu As Long, ByVal un As Long, ByVal bypos As Long, lpcMenuItemInfo As _
MENUITEMINFO)

The parameters are described as follows:
hMenu      Long—Handle of a menu.
un      Long—The menu ID or position of a menu entry. The new entry is inserted before the item specified by this parameter.
bypos      Long—True if un specifies the position of the entry, False if it is a menu ID.
lpMenuItemInfo      MENUITEMINFO—A MENUITEMINFO structure to use to set the characteristics of the specified menu entry.
0
 

Author Comment

by:_alpha
ID: 2734540
Thank you for your help, but isn´t there a solution
whithout the windows API???

Thanks
Alpha
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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

762 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

22 Experts available now in Live!

Get 1:1 Help Now