Notifications
Clear all

[Closed] How to disable icon image

Hi guys,
I’ve noticed that some icon files (like AnimLayerToolbar_24i.bmp) don’t have specific disabled versions of the icon images, but are still grayed out in the Anim Layer Toolbar when the button is disabled. How is this happening? Is there a way to do this for my custom icon images or do I have to gray them out myself in Photoshop and include them in the icon bmp?
Thanks.

8 Replies

it’s probably using

ICustomControl:Disable()

which in turn probably calls the window api function

EnableWindow(HWND hWnd, BOOL bEnable)

Hey Klunk!
Thanks a lot for those links. Unfortunately I don’t know anything about the SDK or C languages. I don’t suppose it’s possible to call these through Maxscript, is it?
Thanks again!

you need to find the HWnd of the control you want to disable then

windows.sendMessage hwnd 10 0 0

may do the job, to enable

windows.sendMessage hwnd 10 1 0

please note I’m just guessing here and may just only disable the control and not grey out, theres plenty of stuff on here about getting the HWnd and theres some examples in the help.

Awesome, that’s more than enough to go on. Thanks.

thinking about it a bit more that probably won’t grey the button out if it’s a standard rollout image button as it will still use it’s usual paint calls.

Tried it and it doesn’t work at all

Hmm, bummer. Well thanks for trying. I was hoping not to have to hand-make disabled versions of each icon :\

try (destroydialog dbuttons) catch()
rollout dbuttons "Image buttons"
(
	local bm = openbitmap (getdir #ui + "icons\BodyObjects_24i.bmp")
	button bt1 width:24 height:24 across:4
	button bt2 width:24 height:24
	button bt3 width:24 height:24
	button bt4 width:24 height:24
	button ena_bt "Enable" width:100 offset:[0,4]
	button dis_bt "Disable" width:100
	
	local btt = #(bt1, bt2, bt3, bt4)
	fn update = 
	(
		w = bm.width/4
		bb = bitmap (bm.width*2) bm.height
		fn grayscale c1 p1 c2 p2 = 
		(
			v = c1.r*0.3 + c1.g*0.59 + c1.b*0.11
			color v v v
		)
		for k=0 to btt.count-1 do
		(
			pastebitmap bm bb (box2 (k*w) 0 w w) [k*2*w,0] 
			pastebitmap bm bb (box2 (k*w) 0 w w) [k*2*w + w,0] type:#function function:grayscale

			btt[k+1].images = #(bb,bb, 8, k*2 + 1, k*2 + 1, (k+1)*2, (k+1)*2, false)
		)
		--display bb
	)
	on ena_bt pressed do btt.enabled = on
	on dis_bt pressed do btt.enabled = off
	on dbuttons open do update()
)
createdialog dbuttons

Ha! That works great! Thanks Denis.