Solved

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

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBScript - Find file starting with XXXX use that in runnig rest of code 9 78
TT Auto Dashboard 13 92
Added a column screws up code 5 57
Excel Automation VBA 19 71
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

803 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