找到办法了,要在PictureBox1元件OnPaint事件
的回调函数里进行设置。
另外还有个麻烦的地方,我每次修改了对话框定义
后要重新开启AutoCAD才能见效。
修改后的lisp代码:

- (defun ObjectDCL_LoadArx ()
- (if (not (member "objectdcl.arx" (arx)))
- (arxload "objectdcl.arx" "ObjectDCL.arx not found.")
- )
- )
- (defun c:hello (/ show_id)
- ; ensure the ObjectDCL.arx file is loaded
- (ObjectDCL_LoadArx)
- ; call the method to load the Hello.odc file.
- (Odcl_LoadProject "hi")
- ; call the method to show the Hellow world dialog box example
- (Odcl_Form_Show hi_DclForm1)
- (princ)
- )
- (defun c:DclForm1_Initialize ()
- (Odcl_Form_SetTitleBarText hi_DclForm1 "大家好!")
- (Odcl_Control_SetProperty hi_DclForm1_Label1 "Caption" "ObjectDCL第一步")
- )
- ;;;下面这个函数好像没有被执行
- (defun c:DclForm1_OnInitialize ()
- (alert "aaa")
- )
- (defun c:DclForm1_TextButton1_OnClicked ()
- (Odcl_Form_Close hi_DclForm1)
- )
- (defun c:DclForm1_TextButton2_OnClicked ()
- (if show_id
- (progn
- (Odcl_PictureBox_Clear hi_DclForm1_PictureBox2)
- (setq show_id nil)
- (Odcl_Control_SetProperty hi_DclForm1_Label1 "Caption" "图片已经清除")
- (Odcl_Control_SetProperty hi_DclForm1_TextButton2 "Caption" "显示图片")
- );progn
- (progn
- (setq fn (findfile "hi.jpg"))
- (if fn
- (progn
- (Odcl_PictureBox_LoadPictureFile hi_DclForm1_PictureBox2 fn)
- (Odcl_Control_SetProperty hi_DclForm1_Label1 "Caption" "拍摄于陈家祠民间艺术博物馆")
- (Odcl_Control_SetProperty hi_DclForm1_TextButton2 "Caption" "清除图片")
- (setq show_id T)
- )
- );if
- )
- );if
- )
- (defun c:DclForm1_PictureBox1_OnPaint (nHasFocus /)
- (c:DclForm1_TextButton2_OnClicked)
- )
|