本帖最后由 yxp 于 2018-6-24 03:12 编辑
DCL 默认对话框是没有菜单的,既然可以调用 windows api 就可以随心所欲了
下面是一个给 DCL 添加菜单的示例,同样的方法可以给 DCL 添加一个右键菜单
- ;;本例将调用 windows api 给 DCL 添加一个完整菜单
- ;; by. yxp_xa 2018年6月23日
- (defun c:sss()
- (setq dcl_id (load_dialog "sss.dcl"))
- (if (not (new_dialog "sss" dcl_id))(exit))
- (add_menu_pop)
- (start_dialog)
- (unload_dialog dcl_id)
- (princ)
- )
- ;;DCL窗口菜单
- (defun add_menu_pop()
- (setq DWX (vlax-create-object "DynamicWrapperX"))
- (vlax-invoke DWX 'Register "user32" "FindWindowExW" "i=hhhw" "r=m")
- (vlax-invoke DWX 'Register "user32" "SetMenu" "i=hh" "r=l")
- (vlax-invoke DWX 'Register "user32" "CreateMenu" "r=l")
- (vlax-invoke DWX 'Register "user32" "CreatePopupMenu" "r=l")
- (vlax-invoke DWX 'Register "user32" "AppendMenuW" "i=plpw" "r=l")
- (setq dcl (vlax-invoke DWX 'FindWindowExW 0 0 0 "DCL窗口菜单示例"))
- (setq hMenu (vlax-invoke DWX 'CreateMenu)) ;;顶级菜单句柄
- (setq menu (mapcar '(lambda(x) ;;创建顶级菜单
- (list (vlax-invoke DWX 'CreatePopupMenu) x))
- (list "文件(&F)" "编辑(&E)" "帮助(&H)"))
- )
- (foreach x menu (vlax-invoke DWX 'AppendMenuW hMenu 16 (car x)(cadr x)))
- (setq pop (list ;;创建子菜单
- '((101 "文件 (&F)")(102 "打开 (&O)...")(103 "保存 (&S)")(104 "关闭 (&C)"))
- '((201 "复制 (&C)")(202 "粘贴 (&P)")(203 "剪切 (&X)"))
- '((301 "帮助 (&H)")(302 "注册 (&R)")(303 "关于 (&A)...")))
- )
- (mapcar '(lambda(x y)(foreach z y
- (vlax-invoke DWX 'AppendMenuW (car x) 0 (car z)(cadr z)))) menu pop)
- (vlax-invoke DWX 'SetMenu dcl hMenu)
- )
- (princ)
源码下载:
dwx自动注册工具下载: |