1. (defun c:tt();此部分是测试代码用
    2. (dcl_bg_load)
    3. )
    4. ;-------------------------------------
    5. (defun dcl_bg_load(/ *error* dcl_file dcl_id dialog_return key keys)
    6. (vl-load-com)
    7. (progn;;;自定义函数
    8. ;-------------------------------------
    9. (defun BF-MListBox-Remrow(/ bf-list-removeindex)
    10. ;;;名称:BF-List-RemoveIndex
    11. ;;;说明:按索引删除列表的项,leemac
    12. ;;;参数:lst:列表
    13. ;;;参数:index:索引,从0开始
    14. ;;;返回:删除索引项之后的列表
    15. ;;;示例:(BF-List-RemoveIndex '(0 1 2 3) 1)
    16. (defun BF-List-RemoveIndex (lst index / i)
    17. (setq i -1)
    18. (vl-remove-if '(lambda (x) (= (setq i (1+ i)) index)) lst)
    19. )
    20. (mapcar
    21. (function
    22. (lambda (tkey)
    23. (set
    24. (read tkey)
    25. (BF-List-RemoveIndex (read tkey) (atoi (get_tile tkey)))
    26. )
    27. (SetContrLst tkey (read tkey))
    28. )
    29. )
    30. (list "序号" "规格" "长度" "材质" "数量")
    31. )
    32. )
    33. (defun BF-MListBox-Selsam(tkey)
    34. (foreach x (vl-remove tkey (list "序号" "规格" "长度" "材质" "数量"))
    35. (set_tile x (get_tile tkey))
    36. )
    37. )
    38. (defun MBF-ListBox-Additm()
    39. (foreach
    40. x
    41. (mapcar
    42. 'list
    43. (list "序号" "规格" "长度" "材质" "数量")
    44. (mapcar
    45. 'append
    46. (list 序号 规格 长度 材质 数量)
    47. (mapcar
    48. (function (lambda (x) (if (= "" (get_tile x)) (list " ") (list (get_tile x)))))
    49. (list "编辑A" "编辑B" "编辑C" "编辑D" "编辑E")
    50. )
    51. )
    52. )
    53. (apply 'SetContrLst x)
    54. (set (read (car x)) (cadr x))
    55. )
    56. )
    57. (defun Start_dcl_bg_Keys(key value istart);控件值初始化
    58. (cond
    59. ((= key "序号");;;{" 序号"} (普通列表)
    60. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    61. (BF-MListBox-Selsam key)
    62. )
    63. ((= key "规格");;;{" 规格"} (普通列表)
    64. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    65. (BF-MListBox-Selsam key)
    66. )
    67. ((= key "长度");;;{" 长度"} (普通列表)
    68. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    69. (BF-MListBox-Selsam key)
    70. )
    71. ((= key "材质");;;{" 材质"} (普通列表)
    72. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    73. ()(BF-MListBox-Selsam key)
    74. )
    75. ((= key "数量");;;{" 数量"} (普通列表)
    76. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    77. (BF-MListBox-Selsam key)
    78. )
    79. ((= key "编辑A");;;{""} (输入框)
    80. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    81. ()
    82. )
    83. ((= key "编辑B");;;{""} (输入框)
    84. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    85. ()
    86. )
    87. ((= key "编辑C");;;{""} (输入框)
    88. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    89. ()
    90. )
    91. ((= key "编辑D");;;{""} (输入框)
    92. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    93. ()
    94. )
    95. ((= key "编辑E");;;{""} (输入框)
    96. (if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
    97. ()
    98. )
    99. )
    100. (prin1)
    101. )
    102. ;-------------------------------------
    103. (defun Action_dcl_bg_Keys(key value);全部控件的点击动作触发
    104. (cond
    105. ((= key "accept");;;{"确认按钮"}
    106. (Get_dcl_bg_Data)
    107. (done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
    108. )
    109. ((= key "cancel");;;{"取消按钮"}
    110. (done_dialog 0);对话框退出返回主函数 传递给Dialog_Return值为0
    111. )
    112. ((= key "读取");;;{"读取"} (按钮)
    113. (Get_dcl_bg_Data)
    114. ()
    115. )
    116. ((= key "清除");;;{"清除"} (按钮)
    117. (Get_dcl_bg_Data)
    118. ()
    119. )
    120. ((= key "编辑行");;;{"编辑行"} (按钮)
    121. (Get_dcl_bg_Data)
    122. ()
    123. )
    124. ((= key "删除行");;;{"删除行"} (按钮)
    125. (Get_dcl_bg_Data)
    126. (BF-MListBox-Remrow)
    127. )
    128. ((= key "添加行");;;{"添加行"} (按钮)
    129. (Get_dcl_bg_Data)
    130. (MBF-ListBox-Additm)
    131. )
    132. (T
    133. (Start_dcl_bg_Keys key value nil);;;其余控件的点击动作触发
    134. )
    135. )
    136. (prin1)
    137. )
    138. ;-------------------------------------
    139. (defun Get_dcl_bg_Data(/ key);临时生成Dcl文件 返回文件名
    140. (foreach key keys
    141. (set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
    142. )
    143. )
    144. ;-------------------------------------
    145. (defun Write_Dcl_dcl_bg(/ Dcl_File file str)
    146. (setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
    147. (setq file (open Dcl_File "w"))
    148. (foreach str '(
    149. "dcl_bg:dialog {"
    150. " label = \"材料输入选项 - From:Dcl-To-Lsp Win_V1.0.5\" ;"
    151. " width = 20 ;"
    152. " :column {"
    153. " :boxed_row {"
    154. " label = \"材料信息\" ;"
    155. " :list_box {"
    156. " height = 25 ;"
    157. " key = \"序号\" ;"
    158. " label = \" 序号\" ;"
    159. " width = 5 ;"
    160. " horizontal_margin = none ;"
    161. " }"
    162. " :list_box {"
    163. " key = \"规格\" ;"
    164. " label = \" 规格\" ;"
    165. " alignment = centered ;"
    166. " horizontal_margin = none ;"
    167. " width = 15 ;"
    168. " }"
    169. " :list_box {"
    170. " key = \"长度\" ;"
    171. " label = \" 长度\" ;"
    172. " horizontal_margin = none ;"
    173. " width = 10 ;"
    174. " }"
    175. " :list_box {"
    176. " key = \"材质\" ;"
    177. " label = \" 材质\" ;"
    178. " horizontal_margin = none ;"
    179. " width = 10 ;"
    180. " }"
    181. " :list_box {"
    182. " key = \"数量\" ;"
    183. " label = \" 数量\" ;"
    184. " horizontal_margin = none ;"
    185. " width = 5 ;"
    186. " }"
    187. " :column {"
    188. " spacer_1;"
    189. " :button {"
    190. " key = \"读取\" ;"
    191. " label = \"读取\" ;"
    192. " }"
    193. " :button {"
    194. " key = \"清除\" ;"
    195. " label = \"清除\" ;"
    196. " }"
    197. " :button {"
    198. " key = \"编辑行\" ;"
    199. " label = \"编辑行\" ;"
    200. " }"
    201. " :button {"
    202. " key = \"删除行\" ;"
    203. " label = \"删除行\" ;"
    204. " }"
    205. " spacer_1;"
    206. " }"
    207. " }"
    208. " :boxed_row {"
    209. " :row {"
    210. " :edit_box {"
    211. " key = \"编辑A\" ;"
    212. " label = \"\" ;"
    213. " horizontal_margin = none ;"
    214. " edit_width = 5 ;"
    215. " }"
    216. " :edit_box {"
    217. " key = \"编辑B\" ;"
    218. " label = \"\" ;"
    219. " horizontal_margin = none ;"
    220. " edit_width = 15 ;"
    221. " }"
    222. " :edit_box {"
    223. " key = \"编辑C\" ;"
    224. " label = \"\" ;"
    225. " horizontal_margin = none ;"
    226. " edit_width = 10 ;"
    227. " }"
    228. " :edit_box {"
    229. " key = \"编辑D\" ;"
    230. " label = \"\" ;"
    231. " horizontal_margin = none ;"
    232. " edit_width = 10 ;"
    233. " }"
    234. " :edit_box {"
    235. " key = \"编辑E\" ;"
    236. " label = \"\" ;"
    237. " horizontal_margin = none ;"
    238. " edit_width = 5 ;"
    239. " }"
    240. " spacer_1;"
    241. " spacer_1;"
    242. " :button {"
    243. " key = \"添加行\" ;"
    244. " label = \"添加行\" ;"
    245. " }"
    246. " }"
    247. " }"
    248. " }"
    249. " ok_cancel;"
    250. "}"
    251. )
    252. (write-line str file)
    253. )
    254. (close file)
    255. Dcl_File
    256. )
    257. ;-------------------------------------
    258. (defun *error*(msg)
    259. ;(foreach key keys;;;释放每个控件变量---可根据个人需要决定是否注释,默认注释!
    260. ; (set (read (strcat key "_bak")) nil)
    261. ;)
    262. (princ "\n命令: *取消*")
    263. (prin1)
    264. )
    265. ;->->-下拉列表初始化函数->->-
    266. (defun SetContrLst(key lst)
    267. (start_list key);下拉列表 {key} 初始化
    268. (mapcar 'add_list lst);添加列表项
    269. (end_list)
    270. (prin1)
    271. )
    272. ;-<-<-下拉列表初始化函数-<-<-
    273. ;->->-图像初始化函数->->-
    274. ;(defun SetContrImg(key imgname)
    275. ; (start_image key);图像 {key} 初始化
    276. ; (fill_image 0 0 (dimx_tile key) (dimy_tile key) 0);图像填充黑色背景
    277. ; (slide_image 0 0 (dimx_tile key) (dimy_tile key) imgname);图像显示SLD幻灯片
    278. ; (end_image)
    279. ; (prin1)
    280. ;)
    281. ;-<-<-图像初始化函数-<-<-
    282. )
    283. (setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl_dcl_bg))));对话框加载
    284. (vl-file-delete Dcl_File);加载后删除DCL文件
    285. (setq Dialog_Return 8)
    286. (while (> Dialog_Return 7) ;循环控制对话框是否结束
    287. (new_dialog "dcl_bg" dcl_id);建立窗体
    288. ;--->--->---对话框初始化--->--->---
    289. (setq keys '("序号" "规格" "长度" "材质" "数量" "读取" "清除" "编辑行" "删除行" "编辑A" "编辑B" "编辑C" "编辑D" "编辑E" "添加行""accept" "cancel" "help" "info"));列表全部控件名称
    290. (foreach x (list "序号" "规格" "长度" "材质" "数量")
    291. (set (read x) keys)
    292. )
    293. ;->->-下拉列表初始化->->-
    294. (SetContrLst "序号" keys);下拉列表 {"序号"}初始化
    295. (SetContrLst "规格" keys);下拉列表 {"规格"}初始化
    296. (SetContrLst "长度" keys);下拉列表 {"长度"}初始化
    297. (SetContrLst "材质" keys);下拉列表 {"材质"}初始化
    298. (SetContrLst "数量" keys);下拉列表 {"数量"}初始化
    299. ;-<-<-下拉列表初始化完成-<-<-
    300. ;(action_tile "accept" "(done_dialog 1)")
    301. ;(action_tile "cancel" "(done_dialog 0)")
    302. (foreach key keys;全部控件的初始化
    303. (Start_dcl_bg_Keys key nil T)
    304. )
    305. (foreach key keys;;;全部控件的点击动作触发
    306. (action_tile key "(Action_dcl_bg_Keys $key $value)");;;点击动作 $reason
    307. )
    308. ;---<---<---对话框初始化完成---<---<---
    309. (setq Dialog_Return (start_dialog));开启对话框(用户可见)
    310. )
    311. (unload_dialog dcl_id);退出时卸载对话框
    312. (cond
    313. ((< 0 Dialog_Return 7) (princ "\n确定"))
    314. ((= Dialog_Return 0) (princ "\n*取消*"))
    315. )
    316. ;(foreach key keys;;;释放每个控件变量---可根据个人需要决定是否注释,默认注释!
    317. ; (set (read (strcat key "_bak")) nil)
    318. ;)
    319. (prin1);防止函数回显
    320. )