[Closed] How to get full viewport's height
here is my version:
fn windowRectAssembly =
(
source = "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "class User32
"
source += "{
"
source += " [DllImport(\"user32.dll\", EntryPoint=\"GetWindowRect\")]
"
source += " static extern bool GetWindowRect(IntPtr hWnd, out POS rect);
"
source += " struct POS
"
source += " {
"
source += " public int Left;
"
source += " public int Top;
"
source += " public int Right;
"
source += " public int Bottom;
"
source += " }
"
source += " public int[] GetWindowRect(Int64 hWnd)
"
source += " {
"
source += " POS rect;
"
source += " if (GetWindowRect((IntPtr)hWnd, out rect))
"
source += " {
"
source += " return new int[] { rect.Left, rect.Top, rect.Right, rect.Bottom };
"
source += " }
"
source += " return new int[4];
"
source += " }
"
source += "}
"
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()
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.
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.BackgroundProgressiveRenderingEnabled <bool>
now…
But i’m sure nobody has any use for this, especially not PowerPreview users
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