Notifications
Clear all

[Closed] closing duplicate .net windows

I have a button that opens a dotnet material browser window. I’d like to know how to close it when I open another such window, as in ‘destroydialog’ in MXS…I’ve had look at howproperties and showevents but can’t seem to locate the right code…Is it form auto invalidate.?..Any help appreciated.

4 Replies
2 Replies
(@gazybara)
Joined: 10 months ago

Posts: 0

What to “close it”?

(@denist)
Joined: 10 months ago

Posts: 0

why do you not want to have duplicated windows?

I don’t want to have cluttered windows. I want to have one only at a time, as any more is untidy and messy, …that’s all. It’s just about user friendliness. I don’t want the user to have to manually close a lot of unnecessary windows, that’s all.

I use this, which searches the open ui’s in max for a given window name.

	
	fn getWindowHandleByWindowText windowText =(
		local ret = #()
		for i in (windows.getChildrenHWND 0P) do(
			if windowText == (UIAccessor.GetWindowText i[1]) then(
				append ret i[1]
			)
		)
		
		return ret
	),--		 getWindowHandleByWindowText "Window Name"

        fn closeWindowHandleByWindowText windowText =(
		
		local allPtrs = this.getWindowHandleByWindowText windowText
		
		for i in allPtrs do (
			UIAccessor.CloseDialog i
		)
	),--		 closeWindowHandleByWindowText "Window Name"


You need to name your dot net window/form.

Hope that helps.