dotnet button visible

Hi everyone

I'm trying to toggle the visibility of a dotnet button inside a maxscript dialog, but I don't find how to get it work so far...

her's my code for now:

try (destroyDialog TestRoll) catch()
 
Rollout TestRoll "TestRoll"
(
 
dotNetControl Btn1 "system.windows.forms.button" width:50 height:50 pos:[5,5]
button Btn2 "toggle visible"
 
on testRoll open do
(
	local logoImg = dotnetObject "System.Drawing.Bitmap" @"C:\bitmap.jpg"
	Btn1.image = logoImg
	Btn1.Visible = false
)	
 
on Btn2 pressed do mmBtn1.Visible = true 
 
 
)
createDialog TestRoll style:#(#style_toolwindow, #style_sysmenu)

So for me the dotnet button should not be visible while the dialog open and should appears when I clic on btn2.
However when the dialog open, Btn1 is white and when I click on Btn2, the Btn1 shows the pictures, while I need the button to be hide or visible (with the picture)

Thanks in advance for any help

Comments

Comment viewing options

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

Update Rollout

You Can use this Function after changing the visibility of dotNetControls

fn refresh_ui rolout = (
	rolout.width += 1 ; rolout.width -= 1
	)
refresh_ui TestRoll 

Thanks to Simont
http://discourse.techart.online/t/maxscript-dotnet-cant-get-button-to-di...

but also you need to change its size coz the space will still occupied with it

(
	local Btns2Hide = #(Btn1)
	fn change_btn_Size orig:true = (
		if orig then (
			for i in Btns2Hide do (i.Size = dotNetObject "System.Drawing.Size" W H) --- restore original size (width height)
		)
		else for i in Btns2Hide do (i.Size = dotNetObject "System.Drawing.Size" 1 1)
	)
)
SugaR's picture

Thanks for your reply

Thanks for your reply Barigazy.

I didn't understand it at first but a bit of research after... Yes it works like a charm !

A big thanks :)

barigazy's picture

...

Use .net panel as dotnet control and add .net button inside.
.net button must be dotnet object

bga

Comment viewing options

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