Home Tour! Products Download Purchase Support Company Contacts  

Question

Is it possible change the picture property in a picture box at run time?

Answer

Pictures are stored internally in the project file as binary information. To change the picture you just set the picture property to the tag value of the picture to be displayed and the control's picture is automatically changed.

This example assumes a picture has been added to the project file and was called 101 and the PictureBox is called PictureBox1.

(defun c:DclForm1_Button_Clicked ()
; clear the picture box of any previously drawn items
(Odcl_PictureBox_Clear TestProject_DclForm1_PictureBox1)
; force the picture box to display the new picture
(Odcl_Control_SetProperty TestProject_DclForm1_PictureBox1_Picture 101)
)

The PictureBox control also has a method to load a picture file directly during runtime.

(defun c:DemoMethods_LoadPictureFile_Clicked (/ sFileName)
; use GetFiled to prompt the user to select a picture file to load
(setq sFileName (GetFiled "Select a picture file"
""
"bmp;ico;jpg;gif;wmf"
8
)
)
; if the picture file is valid
(if (/= sFileName nil)
; force the picturebox to load the picture file to be displayed.
(Odcl_PictureBox_LoadPictureFile
Demo_DemoMethods_PictureBox
sFileName
)
)
)
Home Products Download Purchase Support Company Contacts