[原创]:可视化DCL全自动制作程序
思路:用VB拖一个窗体
用程序分析.frm文件
自动生成DCL代码
自动生成Lisp初始化DCL代码
自动生成注释代码即可.
实现结果:
无需任何DCL知识的学习就可以几分钟做出复杂的DCL界面
同时完成lisp连接和全部控件初始化的程序.
无需任何VB开发知识的学习,只需会简单的拖动出窗体操作即可
示例:程序自动生成代码内容
;----------------------------------------------------------------------------------------
;nonsmall 作品: Visual DCL 对话框自动连接程序
;本代码及注释全部由Visual DCL程序自动生成
(defun c:tt();此部分是测试代码用
(Form1_load)
)
(defun Form1_load( / dcl_id Dialog_Return key keys Dcl_File)
(setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl))));对话框加载
(vl-file-delete Dcl_File);加载后删除DCL文件
(setq Dialog_Return 2)
(while (> Dialog_Return 1) ;循环控制对话框是否结束
(new_dialog "Form1" dcl_id);建立窗体
;-->-->-对话框初始化->-->--
(setq keys '("Command1" "Check1" "Option1" "Text1" "List1" "List3" "Combo1" "HScroll1" "accept" "cancel" "VScroll1" "Picture1" "Image1"));列表全部控件名称
(start_list "List1");直列表 {"List1"} 初始化
(mapcar 'add_list keys);添加列表项
(end_list)
(start_list "List3");直列表 {"List3"} 初始化
(mapcar 'add_list keys);添加列表项
(end_list)
(start_list "Combo1");下拉列表 {"Combo1"} 初始化
(mapcar 'add_list keys);添加列表项
(end_list)
(start_image "Picture1");图像 {"Picture1"} 初始化
(fill_image 0 0 (dimx_tile "Picture1") (dimy_tile "Picture1") 0);图像填充黑色背景
(slide_image 0 0 (dimx_tile "Picture1") (dimy_tile "Picture1") "");图像显示SLD幻灯片
(end_image)
(start_image "Image1");图像 {"Image1"} 初始化
(fill_image 0 0 (dimx_tile "Image1") (dimy_tile "Image1") 0);图像填充黑色背景
(slide_image 0 0 (dimx_tile "Image1") (dimy_tile "Image1") "");图像显示SLD幻灯片
(end_image)
(foreach key keys;全部控件的初始化
(if (eval (read (strcat key "_bak"))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(action_tile key "(Action_Form1_Keys $key $value)");点击动作
)
;--<--<-对话框初始化完成-<--<--
(setq Dialog_Return (start_dialog));开启对话框(用户可见)
)
(unload_dialog dcl_id);退出时卸载对话框
(princ);防止函数回显
)
(defun Action_Form1_Keys (key value) ;全部控件的点击动作触发
(print (list key value))(print "*-------*");测试代码 用后删除
(cond
((= key "accept") ;{确认按钮}
(Get_Form1_Data)
(done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
)
((= key "cancel") ;{取消按钮}
(done_dialog 0);对话框退出返回主函数 传递给Dialog_Return值为0
)
((= key "Command1") ; {"Command1"} (按钮)
()
)
((= key "Check1") ; {"Check1"} (多选按钮)
()
)
((= key "Option1") ; {"Option1"} (单选按钮)
()
)
((= key "List1") ; {} (普通列表)
()
)
((= key "List3") ; {} (普通列表)
()
)
((= key "Combo1") ; {} (下拉列表)
()
)
((= key "HScroll1") ; {} (滑块)
()
)
((= key "VScroll1") ; {} (滑块)
()
)
((= key "Picture1") ; {} (图像按钮)
()
)
((= key "Image1") ; {} (图像按钮)
()
)
)
)
(defun Get_Form1_Data( / key);临时生成Dcl文件 返回文件名
(foreach key keys
(set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
)
)
(defun Write_Dcl( / Dcl_File file str)
(setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
(setq file (open Dcl_File "w"))
(foreach str '(
"/*nonsmall 作品: Visual DCL*/"
"//本代码全部由Visual DCL程序自动生成"
""
"Form1:dialog"
"{"
" label = \"nonsmall 可视化 DCL\";"
" :column"
" {"
" :row"
" {"
" :boxed_column"
" {"
" key = \"Frame1\" ;"
" label = \"按钮\" ;"
" :button"
" {"
" key = \"Command1\" ;"
" label = \"Command1\" ;"
" width = 27.75 ;"
" height = 1.875 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame2\" ;"
" label = \"复选\" ;"
" :toggle"
" {"
" key = \"Check1\" ;"
" label = \"Check1\" ;"
" width = 10.95 ;"
" height = 1.275 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame3\" ;"
" label = \"单选\" ;"
" :radio_button"
" {"
" key = \"Option1\" ;"
" label = \"Option1\" ;"
" width = 13.35 ;"
" height = 1.275 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame4\" ;"
" label = \"文本\" ;"
" :text"
" {"
" key = \"Label1\" ;"
" label = \"Label1\" ;"
" width = 12.15 ;"
" height = 1.275 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame5\" ;"
" label = \"输入\" ;"
" :edit_box"
" {"
" key = \"Text1\" ;"
" width = 14.55 ;"
" height = 0.675 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" }"
" :row"
" {"
" :boxed_column"
" {"
" key = \"Frame6\" ;"
" label = \"单选列表\" ;"
" :list_box"
" {"
" key = \"List1\" ;"
" width = 15.75 ;"
" height = 8.4 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame12\" ;"
" label = \"复选列表\" ;"
" :list_box"
" {"
" key = \"List3\" ;"
" width = 15.75 ;"
" height = 8.4 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" multiple_select = true ;"
" }"
" }"
" :column"
" {"
" :boxed_column"
" {"
" key = \"Frame7\" ;"
" label = \"下拉列表\" ;"
" :popup_list"
" {"
" key = \"Combo1\" ;"
" width = 22.95 ;"
" height = 1.5 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame8\" ;"
" label = \"水平滑块\" ;"
" :slider"
" {"
" key = \"HScroll1\" ;"
" width = 22.95 ;"
" height = 1.275 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" layout = horizontal ;"
" }"
" }"
" :row"
" {"
" :button"
" {"
" key = \"accept\" ;"
" label = \"OK\" ;"
" width = 12.15 ;"
" height = 1.875 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" is_default = true ;"
" }"
" :button"
" {"
" key = \"cancel\" ;"
" label = \"Cancel\" ;"
" width = 12.15 ;"
" height = 1.875 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" is_cancel = true ;"
" }"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame9\" ;"
" label = \"垂\" ;"
" :slider"
" {"
" key = \"VScroll1\" ;"
" width = 2.55 ;"
" height = 7.875 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" layout = vertical ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame10\" ;"
" label = \"图像按钮\" ;"
" :image_button"
" {"
" key = \"Picture1\" ;"
" width = 12.15 ;"
" height = 7.875 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" :boxed_column"
" {"
" key = \"Frame11\" ;"
" label = \"图像\" ;"
" :image"
" {"
" key = \"Image1\" ;"
" width = 12.15 ;"
" height = 7.875 ;"
" fixed_height = true ;"
" fixed_width = true ;"
" }"
" }"
" }"
" }"
"}"
)
(write-line str file))
(close file)
Dcl_File
) 不是很懂,慢慢研究 很不错,仔细学习 我来学习一下 老大,能不能说明一下步骤呢?
谢谢 学习中,先留个记号先,等楼主上来 楼主,程序最好做成附件上传会好点 收集相关资料,准备学习一下 :):):)谢谢,收藏了 谢谢楼主分享!!!
支持楼主的想法 这是拿什么做?
学习中,先留个记号 程序学习,有操作教程吗 实在不会用,怎么连接lisp功能啊
页:
[1]