Change ImgTag bitmap source

Hi all

I made a dialog using ImgTag to place a bitmap on it.
Is there a way to change the bitmap used for the ImgTag, choosing it on a dropdownlist?

Here is my try:

rollout progressTest ("Choose Logo!")
(
  local bm001 = openBitMap("D:\\Test\\logo_001.jpg")
  local bm002 = openBitMap("D:\\Test\\logo_002.jpg")
  imgTag CPanel_BMP "Logo" bitmap:bm001 align:#left 
  dropdownlist LogoList "Choose Logo" items:#("001 - Red Logo","002 - Blue Logo")
)
 
on LogoList selected selID do
(
  MyLogo = "bm" + (substring LogoList.items[selID] 1 3)
  CPanel_BMP.bitmap = MyLogo
)

>> MAXScript Rollout Handler Exception:
-- Type error: set .bitmap requires BitMap, got: #bm002 <<

Someone could help me to understand where I'm wrong?

Thanks in advance,
David

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ahmetss's picture

Problem solved

rollout test "Untitled" width:328 height:539
(
dropdownList 'ddl1' "DropDownList" pos:[16,26] width:288 height:40 items:#("", "1", "2") align:#left
bitmap 'image' "Bitmap" pos:[4,226] width:319 height:200 align:#left

on ddl1 selected sel do
if ddl1.selection==2 then
(
image.filename = @"C:\01.jpg"
)
else
if ddl1.selection==3 then
(
image.filename = @"C:\02.jpg"
)
else
if ddl1.selection==1 then
image.filename = @"C:\03.jpg"
)
Createdialog test

barigazy's picture

...

Post your code or snippet

bga

David_Lee's picture

Oops! You are right,

Oops! You are right, sorry...
I just edit my post, entering the code I tried

barigazy's picture

...

What is the "CustomModel.items" here? I don't see that this is related to any control in rollout

bga

David_Lee's picture

Damn... it's "LogoList", not

Damn... it's "LogoList", not "CustomModel", sorry.

barigazy's picture

...

try(DestroyDialog ::progressTest)catch()
rollout progressTest "LogoRoll"
(
	local logos = #()
	imgTag CPanel_BMP "Logo" align:#left width:80 height:80 pos:[10,10]
	dropdownlist LogoList "Choose Logo:" pos:[10,95] width:80 --items:#("001 - Red Logo","002 - Blue Logo")
 
	on progressTest open do
	(
		local items = #()
		if doesFileExist @"D:\Test\logo_001.jpg" do
		(
			bmp001 = openBitMap (@"D:\Test\logo_001.jpg")
			close bmp001 ; append logos bmp001
			append items "001 - Red Logo" ; CPanel_BMP.bitmap = bmp001
		)
		if doesFileExist @"D:\Test\logo_001.jpg" do
		(
			bmp001 = openBitMap (@"D:\Test\logo_002.jpg")
			close bmp001 ; append logos bmp001 ; append items "002 - Blue Logo"
		)
		LogoList.items = items
	)
	on LogoList selected id do (CPanel_BMP.bitmap = logos[id])
	on progressTest close do (freeSceneBitmaps() ; gc light:on)
)
createDialog progressTest 100 140 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

bga

ahmetss's picture

If options are already added ?

what can be done to get rid of both the code complexity and reduce the base?

exapmle
rollout Test "Untitled" width:162 height:257
(
dropDownList 'ddl7' "DropDownList" pos:[7,19] width:148 height:40 items:#("", "1", "2") align:#left
imgtag 'cust4' "???" pos:[8,118] width:146 height:124 align:#left

on Test open do

if ddl7.selection==2 then
(
bmp001 = openBitMap (@"C:\1.bmp")
cust4.bitmap = bmp001

)
)
createdialog Test

barigazy's picture

...

Chance size of imgTag control to mach size of icon

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.