Get Dialog Position - Render Scene Dialog

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2013   #1
Get Dialog Position - Render Scene Dialog

Is there some hWnd flag for getting dialog positions? I want to work out where my Render Scene Dialog window is via script.....
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 06 June 2013   #2
Originally Posted by DaveWortley: Is there some hWnd flag for getting dialog positions? I want to work out where my Render Scene Dialog window is via script.....

what is your Render Scene Dialog?
are you talking about Render Setup Dialog?
to get its hwnd you have to identify and find it first...
its title text might differ depending on the current renderer, but it keeps "Render Setup:" at the begging. so we can find it by doing something like:

 for hwnd in uiaccessor.getpopupdialogs() where (text = uiaccessor.getwindowtext hwnd) != undefined and matchpattern text pattern:"Render Setup:*" do exit with hwnd
 

Last edited by denisT : 06 June 2013 at 12:34 PM.
 
Old 06 June 2013   #3
I presume you have tried Pete(lonerobot) tool
__________________
Looking in the right side. [bgaTools]
 
Old 06 June 2013   #4
if you want to support any (not just English) versions of max probably you can search by dll filename... but i'm not sure it will work for hieroglyph language systems.
just in case the dll filename is res3.dll
 
Old 06 June 2013   #5
as someone noticed max 2014 has built-in function getWindowPos (or some similar name)
for earlier versions you have to use precompiled one. you can find some samples on this forum.
for example http://forums.cgsociety.org/showpos...679&postcount=9

Last edited by denisT : 06 June 2013 at 12:46 PM.
 
Old 06 June 2013   #6
This one...
RenderSceneDialog.open()


local hWnd = (for w in windows.GetChildrenHwnd 0  where matchPattern w[5] pattern:"Render Setup:*" collect w[1])[1]


This gets me the hWnd for the window, and I can set the position (max 2013) using....


fn createAssembly =
	(		
		str="using System;\n"
		str+="using System.Runtime.InteropServices;\n"
		str+="namespace Win32Helper\n"
		str+="{\n"
		str+="	class Win32HelperClass\n"
		str+="	{\n"		
		str+="		[DllImport(\"user32.dll\")]\n"
		str+="		[return: MarshalAs(UnmanagedType.Bool)]\n"
		str+="		public static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);\n"
		str+="	}\n"
		str+="}\n"

		local csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
		local compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
		compilerParams.ReferencedAssemblies.addRange #("System.dll")
		compilerParams.GenerateInMemory = on
		local compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(str)
		
		for er = 0 to compilerResults.errors.count-1 do print (compilerResults.errors.item[er].tostring())
		return compilerResults.CompiledAssembly.createInstance "Win32Helper.Win32HelperClass"
	)
	
	local win32Helper = createAssembly()


and

win32Helper.setWindowPos hWndIntPtr 0 500 100 0 0 1


I just hoped there was an easier way to get the window position. There is a significant lag with the Render Scene Dialog checking licenses when it opens and I'd prefer to have a macroscript that just moves it off screen and brings it back into position bypassing the need to check the license every time. May sound like a small thing but will make a big difference especially in the heat of the moment at deadline time.

Of course I need to store the position so when I bring it back it pops back into the right place.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 06 June 2013   #7
you are doing everything right. i don't see an easier way by using mxs.
 
Old 06 June 2013   #8
using WH_CTB window hook you theoretically can open any dialog at any place by hooking HCBT_MOVESIZE message.
 
Old 06 June 2013   #9
Opening, setting the position is fine... I need to return a point 2 value for x and y screen positions of an opened dialog...

I'm trying to put some C# code in to do this but I'm not even sure where to go to find out what the method should be called....

I thought it would be something like this... but not sure what I should be doing....

str="using System;\n"
		str+="using System.Runtime.InteropServices;\n"
		str+="namespace Win32Helper\n"
		str+="{\n"
		str+="	class Win32HelperClass\n"
		str+="	{\n"		
		str+="		[DllImport(\"user32.dll\")]\n"
		str+="		[return: MarshalAs(UnmanagedType.Bool)]\n"
		str+="		public static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);\n"
		str+="	}\n"
		str+="	class Win32HelperClass\n"
		str+="	{\n"		
		str+="		[DllImport(\"user32.dll\")]\n"
		str+="		[return: MarshalAs(UnmanagedType.Bool)]\n"
		str+="		public static extern bool GetWindowRect(ByVal hWnd As System.IntPtr, ByRef lpRect As RECT);\n"
		str+="	}\n"
		str+="}\n"
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 06 June 2013   #10
Originally Posted by DaveWortley: Opening, setting the position is fine... I need to return a point 2 value for x and y screen positions of an opened dialog...

I'm trying to put some C# code in to do this but I'm not even sure where to go to find out what the method should be called....


check the link that i showed couple posts above
 
Old 06 June 2013   #11
or look at my script. Its pretty simple once you've registered the windowrect class. The only other way of getting anything to do with the render dialog with mxs is :

rPosArr = filterstring ( getinisetting (getMAXIniFile()) "RenderDialogPosition" "Dimension" ) " "
rPos = [rPosArr[1] as integer, rPosArr[2] as integer]


But this isn't particularly useful, as it wont reflect the actual position, just the last time it was closed.
__________________
Regards,
Pete

Read my technical blog - lonerobot.net
 
Old 06 June 2013   #12
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:59 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.