Can't access HWND in 3dsmax 2020 (here we go again)


#1

Has anyone tried this with 3DSMax 2020?
When I first start max , my command pannel is docked on the right side. I tryed every combinations and get undefined:
commandPanel = windows.getChildHWND #max “Command Panel”
commandPanel = windows.getChildHWND #max “CommandPanelWindow”
commandPanel = windows.getChildHWND 0 “Command Panel”
commandPanel = windows.getChildHWND 0 “CommandPanelWindow”

Now if I make my command panel float , I get a value using this:
commandPanel = windows.getChildHWND 0 “Command Panel”

and when I dock it back, I get a value using this:
commandPanel = windows.getChildHWND #max “Command Panel”

I am trying to get access to the Level of detail functionalities by mimicking the button pressing since we have no functions in Maxscript yet. Any ideas?


#2

I personally hate that kind of code, but it works in 2014 & 2020

fn GetCommandPanelHWND =
(
	local g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance	
	local r  = g.coreinterface7.CommandPanelRollup
	local dialog_hwnd = -1
	
	if r.Hwnd == 0 then
	(
		dialog_hwnd = r.GetPanelDlg 0
		
		for i = 1 to 6 do 
		(
			dialog_hwnd = uiaccessor.getparentwindow dialog_hwnd
		)
	)
	else
	(		
		dialog_hwnd = r.Hwnd
		for i = 1 to 3 do 
		(
			dialog_hwnd = uiaccessor.getparentwindow dialog_hwnd
		)
		
	)
	
	
	dialog_hwnd
)