How to get full viewport's height

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 05 May 2013   #16
Originally Posted by lo: btw, if you are using max2014, you can just use
windows.getWindowPos

oh! at long last!
 
Old 05 May 2013   #17
here is my version:

fn windowRectAssembly =
(
	source  = "using System;\n"
	source += "using System.Runtime.InteropServices;\n"
	source += "class User32\n"
	source += "{\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"GetWindowRect\")]\n"
	source += "		static extern bool GetWindowRect(IntPtr hWnd, out POS rect);\n"
	source += "		struct POS\n"
	source += "		{\n"
	source += "			public int Left;\n"
	source += "			public int Top;\n"
	source += "			public int Right;\n"
	source += "			public int Bottom;\n"
	source += "		}\n"
	source += "		public int[] GetWindowRect(Int64 hWnd)\n"
	source += "		{\n"
	source += "			POS rect;\n"
	source += "			if (GetWindowRect((IntPtr)hWnd, out rect))\n"
	source += "			{\n"
	source += "				return new int[] { rect.Left, rect.Top, rect.Right, rect.Bottom };\n"
	source += "			}\n"
	source += "			return new int[4];\n"
	source += "		}\n"
	source += "}\n"

	csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
					
	compilerParams.GenerateInMemory = true
	compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
	((compilerResults.CompiledAssembly).CreateInstance   "User32").GetWindowRect
)
global getWindowRect = windowRectAssembly()

fn getMaximumViewSize = 
(
	local vp_hwnd = for c in (windows.getchildrenhwnd #max) where c[4] == "ViewPanel" do exit with c[1]
	
/*
	s = getWindowRect vp_hwnd
	[s[3]-s[1]-4, s[4]-s[2]-4] -- not stricly enough because of this (-4)
*/
	
	local xs = #(), ys = #()
	for c in (windows.getchildrenhwnd vp_hwnd) where c[4] == "Label" do 
	(
		s = getWindowRect c[1]
		join xs #(s[1], s[3])
		join ys #(s[2], s[4])
	)
	[amax xs, amax ys] - [amin xs, amin ys]
)
getMaximumViewSize()
 
Old 05 May 2013   #18
Well, that depends on what the OP is trying to achieve... I just thought they want the size of the viewpanel.
 
Old 05 May 2013   #19
Originally Posted by denisT: oh! at long last!


You'll be surprised to hear that they even exposed SetWindowPos
 
Old 05 May 2013   #20
Originally Posted by lo: Well, that depends on what the OP is trying to achieve... I just thought they want the size of the viewpanel.

he asked about maximum size of viewport. it's what getViewSize returns for maximized view.
 
Old 05 May 2013   #21
Originally Posted by lo: You'll be surprised to hear that they even exposed SetWindowPos

wow! so wide expanse opens for rookies.
 
Old 05 May 2013   #22
Originally Posted by denisT: here is my version:

fn windowRectAssembly =
(
	source  = "using System;\n"
	source += "using System.Runtime.InteropServices;\n"
	source += "class User32\n"
	source += "{\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"GetWindowRect\")]\n"
	source += "		static extern bool GetWindowRect(IntPtr hWnd, out POS rect);\n"
	source += "		struct POS\n"
	source += "		{\n"
	source += "			public int Left;\n"
	source += "			public int Top;\n"
	source += "			public int Right;\n"
	source += "			public int Bottom;\n"
	source += "		}\n"
	source += "		public int[] GetWindowRect(Int64 hWnd)\n"
	source += "		{\n"
	source += "			POS rect;\n"
	source += "			if (GetWindowRect((IntPtr)hWnd, out rect))\n"
	source += "			{\n"
	source += "				return new int[] { rect.Left, rect.Top, rect.Right, rect.Bottom };\n"
	source += "			}\n"
	source += "			return new int[4];\n"
	source += "		}\n"
	source += "}\n"

	csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
					
	compilerParams.GenerateInMemory = true
	compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
	((compilerResults.CompiledAssembly).CreateInstance   "User32").GetWindowRect
)
global getWindowRect = windowRectAssembly()

fn getMaximumViewSize = 
(
	local vp_hwnd = for c in (windows.getchildrenhwnd #max) where c[4] == "ViewPanel" do exit with c[1]
	
/*
	s = getWindowRect vp_hwnd
	[s[3]-s[1]-4, s[4]-s[2]-4] -- not stricly enough because of this (-4)
*/
	
	local xs = #(), ys = #()
	for c in (windows.getchildrenhwnd vp_hwnd) where c[4] == "Label" do 
	(
		s = getWindowRect c[1]
		join xs #(s[1], s[3])
		join ys #(s[2], s[4])
	)
	[amax xs, amax ys] - [amin xs, amin ys]
)
getMaximumViewSize()


I've test ,works like a charm.thanks
 
Old 05 May 2013   #23
you even can set the viewpanel to any arbitrary size via script now ( at least in Nitrous), totally independent from the application window dimensions

nitrousgraphicsmanager.PinViewPanelSize <integer>width <integer>height
nitrousgraphicsmanager.UnpinViewPanelSize()

or the whole application window

nitrousgraphicsmanager.SetAppWindowSize <integer>width <integer>height
nitrousgraphicsmanager.SetAppWindowPos <integer>x <integer>y


And there's
nitrousgraphicsmanager.BackgroundProgressiveRender  ingEnabled  <bool>


now...
But i'm sure nobody has any use for this, especially not PowerPreview users


Quote: what does it do if the active view is 0? (any extended viewport)


It simply captures the whole viewpanel DIB region.
Meaning you can't really use it for viewport captures (as i suggested above), becuase you always would get overlapping max windows with this capture method. But for viewpanel size info it's enough
__________________

PowerPreview: High Quality Nitrous Previews for 3ds Max 2012|2013|2014

[ Free Download (ScriptSpot) ]

Home of The Frogs | Online Portfolio
 
Old 05 May 2013   #24
Originally Posted by spacefrog: now...
But i'm sure nobody has any use for this...

oh! how much the max was littered in recent times...
 
Old 05 May 2013   #25
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 08:24 AM.


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