Notifications
Clear all

[Closed] Get ModifyPanel Height

 MZ1

Any body knows how we can get height of this area?

7 Replies

try GetClientRect or windows.getWindowPos in max2014+

ptr = dotNetObject "System.IntPtr" (windows.getMAXHWND())
rect = (dotNetClass "Autodesk.Max.GlobalInterface").Instance.box2.create asdotnetobject:true
format "%:%  %:%\n" rect.x rect.y rect.w rect.h
	
(dotNetClass "Autodesk.Max.GlobalInterface").Instance.GetClientRectP ptr rect
	
format "%:%  %:%\n" rect.x rect.y rect.w rect.h
 MZ1

Thank You!, But my question is how we can find handler of that area?

Maybe one of these could help. Don’t know if it will work in newer max versions

 MZ1

Yea It helps, After comparing children of “ModifyTask”, I guess the child number 2 is the area that I was looking for. So this code works perfectly for me:

fn GetClientRect Handler = 
(
	GlobalInterface = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
	Rect = GlobalInterface.box2.create asdotnetobject:true
	GlobalInterface.GetClientRectP (dotNetObject "System.IntPtr" Handler) Rect
	Rect
)

fn ModifyPanelClientRect = 
(
	ModifyPanel_hwnd = for c in windows.getChildrenHWND #max where c[4] == "ModifyTask" do exit with c[1]
	-- I guess this is the area that we want:
	ChildId = 2
	Handler = (windows.getChildrenHWND ModifyPanel_hwnd)[ChildId][1]
	Rec = GetClientRect Handler
	ScreenPos = windows.clientToScreen Handler [0,0]
	[ScreenPos.x,ScreenPos.y,Rec.h,Rec.w]
)

-- Test
Rec = ModifyPanelClientRect()
try(Window.close())catch()
Window = dotnetobject "system.windows.window"
-- Window.WindowStyle = Window.WindowStyle.None
Window.ResizeMode = Window.ResizeMode.NoResize
Window.Left = Rec[1]
Window.Top = Rec[2]
Window.height = Rec[3]
Window.width = Rec[4]
Window.show()
 MZ1

As you said another problem is how to make it work in version 2018 and above?

It was probably renamed. You can easily find it with Spy++
%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\spyxx_amd64.exe

 MZ1

Well… I found the names by finding parent of custom attribute’s rollout. But I should test the Spy++, Thanks!
This is the code that I tested with Max 2014,2016,2018,2019:

fn GetCommandPanelClientArea = 
(
	MaxVer = (1998 + (maxVersion())[1]/1000)
	Handler = undefined
	case MaxVer of
	(
		(2018):
		(
			for c in windows.getChildrenHWND #max where c[5] == "qt_tabwidget_stackedwidgetWindow" while Handler == undefined do
				for cc in windows.getChildrenHWND c[1] where cc[5] == "3dsmax" while Handler == undefined do
					for ccc in windows.getChildrenHWND cc[1] where ccc[5] == "3dsmax" while Handler == undefined do Handler = ccc[1]
		)
		
		(2019):
		(
			for c in windows.getChildrenHWND #max where c[5] == "CommandPanelWindow" while Handler == undefined do
				for cc in windows.getChildrenHWND c[1] where cc[5] == "MaxSDK::QmaxRollupContainerWindow" while Handler == undefined do Handler = cc[1]
		)
		
		Default:
		(
			for c in windows.getChildrenHWND #max where c[4] == "ModifyTask" while Handler == undefined do
				for cc in windows.getChildrenHWND c[1] where cc[4] == "GRAY" while Handler == undefined do Handler = cc[1]
		)
	)
	Rect = Windows.getWindowPos Handler ; Rect = [Rect.x,Rect.y,Rect.w,Rect.h]
)

Rect = GetCommandPanelClientArea()
try(Window.close())catch()
Window = dotnetobject "system.windows.window"
Window.Left = Rect[1]
Window.Top = Rect[2]
Window.width = Rect[3]
Window.height = Rect[4]
Window.WindowStyle = Window.WindowStyle.None
Window.ResizeMode = Window.ResizeMode.NoResize
Window.show()