CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

菜单栏属性 (ActiveX)

2023-1-3 11:07| 发布者: admin| 查看: 393| 评论: 0|来自: AutoCAD

摘要: 获取会话的菜单栏对象。

获取会话的菜单栏对象。

支持的平台:仅窗口

签名

工 务 局:

object.MenuBar 
对象

类型:应用

此属性适用的对象。

属性值

只读:是的

类型:菜单栏

会话的对象。MenuBar

言论

没有额外的评论。

例子

工 务 局:

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

Visual 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!")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 09:04

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部