|
-
Oct 13th, 2000, 01:53 PM
#1
Thread Starter
New Member
I need to be able to create a control array of menu items created dynamically in code rather than at design time using the menu editor.
Any help gratefully received!
Matt
-
Oct 13th, 2000, 01:55 PM
#2
Have all the option on the menu and set them to invisible... when you need.. make them visible
-
Oct 13th, 2000, 02:08 PM
#3
Try this:
Code:
'Code from Megatron
Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Private Declare Function CreatePopupMenu Lib "user32" () As Long
Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, ByVal lprc As Any) As Long
Const MF_STRING = &H0&
Private Type POINTAPI
x As Long
y As Long
End Type
Private hMenu As Long
Private PT As POINTAPI
Private Sub Form_Load()
hMenu = CreatePopupMenu()
AppendMenu hMenu, MF_STRING, 0, "New Menu"
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call GetCursorPos(PT)
If Button = 2 Then
TrackPopupMenu hMenu, 0, PT.x, PT.y, 0, hwnd, 0&
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
DestroyMenu hMenu
End Sub
-
Oct 13th, 2000, 02:08 PM
#4
Frenzied Member
Try this article for your answer...
http://msdn.microsoft.com/library/de...satruntime.htm
Tells you how to do it. If you haven't already, bookmark MSDN's web site. It is an invaluable source of information for programming questions!
Hope that helps,
-
Oct 13th, 2000, 02:24 PM
#5
You said you wanted to create it from a Control Array? In order to do this, you must have at least one instance of that menu.
Make a menu with a sub menu and call the sub menu mnuSub. Add the following code to a CommandButton to allow for more menus to be added.
Code:
Private Sub Command1_Click()
i = mnuSub.Count
Load mnuSub(i)
mnuSub(i).Caption = "New Menu"
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|