|
-
June 25th, 2001, 11:28 PM
#1
Menu
How can I trap the Event generated by a menu, which is created at runtime in Visual Basic 6.
I have created a menu at runtime using the Load function for the Menu Control Array element. This menu is now attached to a different Form using the AppendMenu API Function . How can I trap the event generated by this menu in the new Form?
Code used to populate and attach the menu to the new form is given below
HndlMenu = GetMenu(Forms(0).hwnd)
frmdiaTime.mnuMainPopupMenu.Visible = true
HndlMenu = GetSubMenu(HndlMenu, 8)
for intCount = 1 to GetMenuItemCount(HndlMenu) - 1
Unload Forms(0).mnuPopupReports(intCount)
next
intCount = 0
'Populate the reports menu of the MDI Form
While Not rsReports.EOF
If intCount > 0 then Load Forms(0).mnuPopupReports(intCount)
Forms(0).mnuPopupReports(intCount).Caption = rsReports!Text
Forms(0).mnuPopupReports(intCount).Tag = rsReports!ReportID
Forms(0).mnuPopupReports(intCount).Visible = true
intCount = intCount + 1
rsReports.MoveNext
Wend
'get the handle to the MdiForm's main menu
HndlMenu = GetMenu(Forms(0).hwnd)
'get the handle to the reports submenu (popup)
HndlPopup = GetSubMenu(HndlMenu, 8)
'get the menu container forms' main menu bar
HndlMenu = GetMenu(frmMenuContainer.hwnd)
'get the first submenu
HndlSubMenu = GetSubMenu(HndlMenu, 0)
'Attach the Report popup menu
returnvalue = InsertMenu(HndlSubMenu, 0, MF_POPUP, HndlPopup, "Reports")
'Redraw the menu bar
SetMenu frmMenuContainer.hwnd, HndlMenu
How can I trap the event of the new appended menu in the form frmMenuContainer
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
|