Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2000-04-17
4
Medium Priority
?
198 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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

916 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