如何将菜单项与窗体关联?
我新建立了一个工程,然后在AutoCAD对象中的thisdrawing内编写了一个菜单,其中有一个菜单项为“水力解析”,然后再在窗体中新创建了一个窗体“slph”,该窗体功能为进行水力平衡计算,我想要得结果是:单我点击菜单项“水力解析”时,自动将窗体“slph”调出显示,但是我发现无法与我的窗体关联!代码如下:请高手指教
Option Explicit
Sub Ch6_AddAMenuItem() Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' 建立一个新菜单 Dim newMenu As AcadPopupMenu Set newMenu = currMenuGroup.Menus.Add("灌溉")
' 在新菜单中增加菜单项 Dim newMenuItem As AcadPopupMenuItem Dim openMacro, openMacro1, openMacro2, openMacro3, openMacro4 As String
' 赋值宏字符串并创建菜单项 openMacro = Chr(3) + Chr(3) + Chr(95) + "open" + Chr(32) openMacro1 = Chr(3) + Chr(3) + Chr(95) + "close" + Chr(32) openMacro2 = Chr(3) + Chr(3) + Chr(95) + "saveas" + Chr(32) openMacro3 = Chr(3) + Chr(3) + Chr(95) + "quit" + Chr(32) openMacro4 = slphform.Show '就是她提示变量未定义,我觉得不需要呀,如果有很多的窗体需要调用难道都要定义?????? Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _ "打开", openMacro) Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _ "关闭当前图形", openMacro1) Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _ "另存为...", openMacro2) Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _ "关闭AUTOCAD", openMacro3) Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _ "水力计算", openMacro4)
' 在菜单条上显示菜单 newMenu.InsertInMenuBar _ (ThisDrawing.Application.MenuBar.Count + 1) End Sub
请那位高手能够解答,多谢了!
ybhfau@sina.com |