Solved

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

Posted on 2000-04-17
4
170 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

828 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