|
-
Dec 8th, 1999, 05:09 PM
#1
Thread Starter
Member
-
Dec 8th, 1999, 07:19 PM
#2
Frenzied Member
First of all I haven't tested this 
It's not runnable code anyway but it might point you in the right direction!
If you need more help I might be able to dig out a runnable sample.
Code:
Public Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
' Menus
Public Declare Function CreateMenu Lib "user32" () As Long
Public Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
Public Declare Function SetMenu Lib "user32" (ByVal hWnd As Long, ByVal hMenu As Long) As Long
Public Declare Function InsertMenuItem Lib "user32" Alias "InsertMenuItemA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, ByRef lpcMenuItemInfo As MENUITEMINFO) As Long
Public Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long
Public Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company
-
Dec 8th, 1999, 07:39 PM
#3
Thread Starter
Member
-
Dec 8th, 1999, 08:29 PM
#4
Lively Member
I'm not too sure if I understand your problem but I think this may help. If you are looking to create a menu with a dynamic number of entries then open the menu editor and create a top level menu i.e. mnuFile. Create a sub menu item, call it mnuMain and give it an index of 0. Then paste the code below into the form. You'll see that if you change the value of nRandom in the Form_Load event you get that number of entries.
Option Explicit
Private Sub Form_Load()
Dim nRandom As Integer
Dim i As Integer
nRandom = 10
For i = 1 To nRandom
Load mnuMain(i)
mnuMain(i).Caption = i
Next
End Sub
Private Sub mnuMain_Click(Index As Integer)
MsgBox "clicked in menu item " & i
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
|