Bring (render setup dialog )to front


#1

i sometimes work with slate editor maximized and sometimes the render setup dialog becomes behind it

is there a way using maxscript to bring it to front without closing and opening it again ?


#2

trickiest part is to get its hwnd

if not tabbedDialogs.isOpen #render then renderSceneDialog.open() else
(
	local g                    = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
	local class_id             = tabbedDialogs.getDialogID #render
	local TAB_DIALOG_RENDER_ID = g.class_id.Create class_id[1] class_id[2]

	local render_tabbed_dialog = g.TabDialogManager.GetTabbedDialog TAB_DIALOG_RENDER_ID

    windows.sendMessage render_tabbed_dialog.Hwnd 0x112 0xF120 0 -- restore
	windows.sendMessage render_tabbed_dialog.Hwnd 0x7 0 0 -- set focus
)

#3

thank you for this code, much faster than mine

for m in windows.getChildrenHWND 0 where matchpattern m[5] pattern:"Render Setup*" and m[6] == windows.getMAXHWND() do ((dotNetObject "MaxCustomControls.Win32API").BringWindowToTop (dotnetObject (dotnetClass "System.intPtr") m[1]))

maybe because of the matchpattern that needs to parse a lot of data, thank you


#4

no, its because of lots of child windows of the desktop and the fact that you don’t cache max hwnd and call windows.getMAXHWND() on every iteration . Try to stop the loop after you bring window to the top, it should work faster
btw. your code perhaps won’t work for localized max version like spanish, or chinese sinсe there won’t be ‘Render Setup’ phrase in the title


#5

that’s an old question i haven’t solved yet, how can i cache the result of a native function in a variable? if you can point me to the reference i’d ve very happy. i have had this problem quite a few times.

for the matchpattern, i don’t like it too but didn’t tought about using the global interface, so thank you!


#6

By caching in mxs it usually means to store the value/function in a local variable to minimize mem consumption and also to speed things up.
Did you notice that BringWindowToTop doesn’t restore minimized render settings dialog?

local max _hwnd = windows.getMAXHWND()
for m in windows.getChildrenHWND 0 where matchpattern m[5] pattern:"Render Setup*" and m[6] == max_hwnd do ...

and this should work even faster since hwnd equality check is way cheaper than matchpattern

local max _hwnd = windows.getMAXHWND()
for m in windows.getChildrenHWND 0 where m[6] == max_hwnd  and matchpattern m[5] pattern:"Render Setup*" do ...

You can find more in maxscript faq ‘MAXScript FAQ > How To Make It Faster?’ in the reference


#7

ok, that’s what i used to do.

the thing i meant is, let say the function is not windows.getMAXHWND() but something that changes over time.

i cant recall right now the exact situation in which i had this problem but everytime i called the variable it would re-evaluate and update. even if i did a copy of the result it was kind of linked. i know it’s a bit OT, maybe i’ll open a new thread as soon as i can remember when i had this problem


#8

this is the real code i used to use

local max_hwnd = windows.getMAXHWND()
	local handle = undefined
	for m in windows.getChildrenHWND 0 while handle == undefined where m[4] == "Qt5QWindow" and matchpattern m[5] pattern:"Render Setup*" and m[6] == max_hwnd do handle = m[1]

	RSetupHwnd = handle

but i didnt remember where i was storing it :smiley:

so i patched it up quickly for this post


#9

Thanks alot guys so much help will dig into them and get back to you