Primary screen width & height - DOTnet

Hello,

I tried to align my rollout to the center of the screen. First of all i tried to get the screen resolution by maxscript:

sysInfo.desktopSize

The problem is that it shows us the full resolution of all monitors, but i need just the primary screen resolution.

There is a nice DOTnet function for it: "Screen.PrimaryScreen.Bounds.Width" & "Screen.PrimaryScreen.Bounds.Height".
My problem is: How can i use it in maxscript? I tried it on this way:

 local screenWidth = dotNetObject "Screen.PrimaryScreen.Bounds.Width"

...but don't works.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Matyrix's picture

I couldn't solve this so big

I couldn't solve this so big thanks for the answer! :)

Anubis's picture

freeVBcode is very useful

freeVBcode is very useful site but what is missed in that function is the parent name space (System.Windows.Forms). i know you solve this but lets post this for the others ;)

fn ScreenResolution = (
	local scr = dotNetClass "System.Windows.Forms.Screen"
	[scr.PrimaryScreen.Bounds.Width, scr.PrimaryScreen.Bounds.Height]
)
--OR...
fn ScreenResolution = (
	local scr = (dotNetClass "System.Windows.Forms.Screen").PrimaryScreen.Bounds
	[scr.Width, scr.Height]
)

my recent MAXScripts RSS (archive here)

Matyrix's picture

Otherwise i found this DOTnet

Otherwise i found this DOTnet solution on this site: http://www.freevbcode.com/ShowCode.Asp?ID=5915

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.