Wont load image in rollout dialog


#1

Hello all. Im not programmer or script writer, but need help some scripting in maxscript. I tryng made simple scene loader with image previews with png imge, but png not load in the rollout box. Is there someone, who can correct my script?

Script itself is…

rollout rollScenes "Stuudios One" width:670 height:132
	(
	groupBox gr_smallsc "Stuudiod üks" pos:[0,0] width:669 height:131

	dotNetControl sceneTh_S1 "System.Windows.Forms.PictureBox" pos:[6,20] width:130 height:98

	on sceneTh_S1 DoubleClick arg do 
	(

			loadMaxFile ((getDir #maxroot) + "\\scripts\\Studios\\Studio1.max") useFileUnits:true quiet:true;
			max file saveas

	)	
	fn fillScenesTh =
	(
	sceneTh_S1.Image = sceneTh_S1.FromFile ((getDir #maxroot) + "\\scripts\\Studios\\Studio1.png")
	)

)
	
createdialog rollScenes

Script is little messed and one more time, im not expert this stuff, but there is someting wrong. Thanks for help.


#2

The problem is that although you have defined a function to load a bitmap it is not called anywhere, so it is sitting there waiting for someone to call it. You could all it when the Rollout opens like:

rollout rollScenes "Stuudios One" width:670 height:132
(
	groupBox gr_smallsc "Stuudiod üks" pos:[0,0] width:669 height:131
	dotNetControl sceneTh_S1 "System.Windows.Forms.PictureBox" pos:[6,20] width:130 height:98

	on sceneTh_S1 DoubleClick arg do 
	(
		loadMaxFile ((getDir #maxroot) + "\\scripts\\Studios\\Studio1.max") useFileUnits:true quiet:true
		max file saveas
	)
	
	fn fillScenesTh =
	(
		-- Define the path of your image
		imgPath = (getDir #maxroot) + "\\scripts\\Studios\\Studio1.png"
		
		-- Check if the file exists
		if doesfileexist imgPath then
		(
			-- Create .Net bitmap object from the file
			img = dotnetObject "System.Drawing.Bitmap" imgPath
			-- Assign the bitmap to the .Net control
			sceneTh_S1.Image = img
		)else(
			-- Create and display a messagebox if the file do not exist
			msg  = "Could not locate the following file:\n"
			msg += imgPath
			messagebox msg
		)
	)
	
	-- When this rollout opens call the function to load your images
	on rollScenes open do
	(
		fillScenesTh()
	)
)

createdialog rollScenes

#3

It works. Thank you very much!