CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoLISP 开发指南

示例:隐藏对话框 (DCL)

2023-1-6 09:15| 发布者: admin| 查看: 451| 评论: 0|来自: AutoCAD

摘要: 此示例演示如何创建一个简单的对话框,该对话框允许用户单击按钮,然后在图形屏幕中选取一个点。

此示例演示如何创建一个简单的对话框,该对话框允许用户单击按钮,然后在图形屏幕中选取一个点。

该对话框使用以下 DCL 定义:

hidedcl : dialog
{
  label="Hide Example";
  : column
  {
    : text
    {
      key="message";
      label="Click PickMe to pick a point";
      fixed_width=true;
      fixed_height=true;
      alignment=centered;
    }
    :row
    {
      ok_only;
      :retirement_button
      {
        label = "PickMe";
        key = "hide";
        mnemonic = "H";
      }
    }
  }
}

对话框定义定义用户可以单击的两个按钮。单击“确定”关闭窗口,同时单击“选取我”将执行隐藏对话框并提示用户指定点的代码。以下 AutoLISP 代码显示对话框并定义两个按钮磁贴的行为:

(defun c:hidedcl (/ dcl_id what_next cnt)
  (setq dcl_id (load_dialog "hidedcl.dcl"))  ; Load the dialog box.
  (setq what_next 2)
  (setq cnt 1)
  (while (>= what_next 2)                    ; Begin display loop.
    (if (null (new_dialog "hidedcl" dcl_id)) ; Initialize dialog
      (exit)                                 ; box, exit if nil
    ) ; endif                                ; returned.

    ; Set action to take if a button is pressed. Either button
    ; results in a done_dialog call to close the dialog box.
    ; Each button associates a specific status code with
    ; done_dialog, and this status code is returned by
    ; start_dialog.
    (action_tile "accept" "(done_dialog 1)") ; Set action for OK.
    (action_tile "hide" "(done_dialog 4)")   ; Set action for PickMe.
    (setq what_next (start_dialog))          ; Display dialog box.

    (cond
      ((= what_next 4)                       ; Prompt user to
        (getpoint "\npick a point")          ; pick pt.
      )
      ((= what_next 0)
        (prompt "\nuser cancelled dialog")
      )
    )
  )
  (unload_dialog dcl_id)
 (princ)
)
注意:该函数一次终止所有对话框,但不返回状态代码,因此应用程序无法区分隐藏嵌套框和由于错误条件而取消框。term_dialog

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 12:12

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部