ScriptSpot

Forum topic · General Scripting

dotnet button visible

By SugaR · 2013-10-11

Description

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 (3)

Update Rollout

obaida · 2020-07-07

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 · 2013-10-11

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 · 2013-10-11

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