MenuBar 属性 (ActiveX)
获取会话的 MenuBar 对象。 支持的平台:仅限 Windows 言论没有其他评论。 例子VBA: Sub Example_MenuBar()
' This example uses MenuBar to obtain a reference to the AutoCAD File menu.
' It then creates a new menu item and inserts it at the bottom of the File menu.
'
' The menu item will be automatically removed when AutoCAD is restarted
Dim menu As AcadPopupMenu, newMenuItem As AcadPopupMenuItem
Dim openMacro As String
On Error GoTo ERRORTRAP
' Use MenuBar property to obtain reference to the AutoCAD File menu
Set menu = ThisDrawing.Application.MenuBar.Item("&File")
' Add a menu item to the new menu and
' assign an Open macro (VBA equivalent of: "ESC ESC _open ")
openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32)
' Add a menu separator
menu.AddSeparator (menu.count + 1)
' Add new menu item to File menu
Set newMenuItem = menu.AddMenuItem(menu.count + 1, "NEW MENU ITEM", openMacro)
MsgBox "A new menu item has been added to the File menu!"
Exit Sub
ERRORTRAP:
MsgBox "The following error has occurred: " & Err.Description
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_MenuBar()
;; This example uses MenuBar to obtain a reference to the AutoCAD File menu.
;; It then creates a new menu item and inserts it at the bottom of the File menu.
;;
;; The menu item will be automatically removed when AutoCAD is restarted
(setq acadObj (vlax-get-acad-object))
;; Use MenuBar property to obtain reference to the AutoCAD File menu
(setq menu (vla-Item (vla-get-MenuBar acadObj) "&File"))
;; Add a menu item to the new menu and
;; assign an Open macro (VBA equivalent of: "ESC ESC _open ")
(setq openMacro (strcat (Chr 3) (Chr 3) (Chr 95) "open" (Chr 32)))
;; Add a menu separator
(vla-AddSeparator menu (1+ (vla-get-Count menu)))
;; Add new menu item to File menu
(setq newMenuItem (vla-AddMenuItem menu (1+ (vla-get-Count menu)) "Open File" openMacro))
(alert "A new menu item has been added to the File menu!")
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 09:57
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.