|
-
Aug 17th, 2000, 10:25 AM
#1
Thread Starter
Addicted Member
I know the code to create a popupmenu and fill it with items. Here is the code:
Code:
Public Declare Function CreatePopupMenu Lib "user32.dll" () As Long
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
Public Declare Function InsertMenuItem Lib "user32.dll" Alias "InsertMenuItemA" (ByVal _
hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As _
MENUITEMINFO) As Long
Dim hPopupMenu As Long
Dim mii As MENUITEMINFO
Dim retval As Long
'inside an event procedure
hPopupMenu = CreatePopupMenu()
With mii
.cbSize = Len(mii)
.fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
.fType = MFT_STRING
.fState = MFS_ENABLED Or MFS_DEFAULT
.wID = ID_ABOUT
.dwTypeData = "&About This Example..."
.cch = Len(.dwTypeData)
End With
retval = InsertMenuItem(hPopupMenu, 0, 1, mii)
This will produce an menu item for popupmenu. But I tried to change the ftype, fmask value to create submenu or submenu array within popupmenu without success.
Anyone could help me?
-
Aug 17th, 2000, 10:41 AM
#2
_______
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 17th, 2000, 11:09 AM
#3
Thread Starter
Addicted Member
Thanks. That is the place I got above code. The sample doesn't address how to creat submenu issue.
-
Aug 17th, 2000, 11:19 AM
#4
Fanatic Member
Where there's a will, there's a dozen long lost nephews
If .fmask add Or MIIM_SUBMENU and in .hSubMenu add the handle to a menu which is the submenu (this could be one created eith VB's menu editor, or by CreatePopupMenu)
-
Aug 17th, 2000, 12:33 PM
#5
Thread Starter
Addicted Member
Thanks V(ver)y Basic, I am still struggling to get it work
Here is the code
Code:
hsubMenu = CreatePopupMenu() 'create submenu
With mii
.cbSize = Len(mii)
.fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE or miim_submenu
.fType = MFT_STRING or MFT_MENUBREAK
.fState = MFS_ENABLED Or MFS_DEFAULT
.wID = 1
.dwTypeData = "subMenu Item"
.cch = Len(.dwTypeData)
End With
retval = InsertMenuItem(hsubMenu, 0, 1, mii) 'insert first submenu item
hPopupMenu=CreatePopupMenu() ' Create popup menu
With mii
.cbSize = Len(mii)
.fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
.fType = MFT_STRING
.fState = MFS_ENABLED Or MFS_DEFAULT
.wID = 2
.dwTypeData = "menu item"
.cch = Len(.dwTypeData)
.hsubmenu = hsubmenu
End With
retval = InsertMenuItem(hPopupMenu, 0, 1, mii)
Only first level menu shows up. Any Help?
[Edited by Winla on 08-17-2000 at 02:05 PM]
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
|