;; 向猫老师学习
;; 优化代码- (defun c:tt ()
- (command "opendcl")
- (dcl_project_load "dynamic.odcl" t)
- (dcl_form_show dynamic_form1)
- (Setq wmp (vlax-Create-Object "WMPlayer.OCX"))
- (Vlax-Put-Property wmp 'URL (findfile "Change.wav"))
- (move 1 95 65)
- )
- (defun c:dynamic_Form1_TextButton1_OnClicked (/)
- (move 1 95 65)
- (Vlax-Put-Property wmp 'URL "Change.wav")
- )
- (defun c:dynamic_Form1_TextButton2_OnClicked (/)
- (move 2 255 65)
- (Vlax-Put-Property wmp 'URL "Change.wav")
- )
- (defun c:dynamic_Form1_TextButton3_OnClicked (/)
- (move 3 255 225)
- (Vlax-Put-Property wmp 'URL "Change.wav")
- )
- (defun move (index n1 n2 / str i d2 d3)
- (setq str "dynamic_Form1_GraphicButton"
- d2 dynamic_Form1_TextButton2
- d3 dynamic_Form1_TextButton3
- lst (cond ((= index 1) '(0 255 255 215 215 175 175 135 135))
- ((= index 2) '(0 225 225 185 185 145 145 105 105))
- ((= index 3) '(0 195 195 155 155 115 115 75 75))
- )
- i 1
- )
- (dcl_Control_SetTopFromBottom d2 n1)
- (dcl_Control_SetTopFromBottom d3 n2)
- (repeat 8
- (dcl_Control_SetTopFromBottom
- (eval (read (strcat str (itoa i))))
- (nth i lst)
- )
- (dcl_Control_SetPicture
- (eval (read (strcat str (itoa i))))
- (+ 100 i (* (- index 1) 8))
- )
- (setq i (1+ i))
- )
- )
|