Solved

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

Posted on 2000-04-17
4
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 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