Notifications
Clear all

[Closed] windows.setWindowPos

Hi!

windows.setWindowPos 66842P 0 0 500 500 true

With this i can change position and resize 3ds max main window, but 66842P is HWND and changed when max starts. HWND we can receive with windows.getMAXHWND()

how correctly to write an expression?

windows.setWindowPos windows.getMAXHWND() 0 0 500 500 true

But the main question is if we can change size of max window, can we maximize it, to make display over windows taskbar? Like fullscreen mode.

Thanks

23 Replies
1 Reply
(@denist)
Joined: 2 years ago

Posts: 0
windows.setWindowPos (windows.getMAXHWND()) 0 0 500 500 true

there is an easier way:

WM_SYSCOMMAND = 0x0112
SC_MAXIMIZE = 0xF030
windows.sendmessage (windows.getmaxhwnd()) WM_SYSCOMMAND SC_MAXIMIZE 0
2 Replies
(@blyskawka)
Joined: 2 years ago

Posts: 0

Thanks Denis it works, but it just maximize window, taskbar is still visible. Is it possible to maximize window over taskbar? Something like “ontop”

(@denist)
Joined: 2 years ago

Posts: 0

everything is possible but are you sure that you really need it?
most artists who works with editors like max, maya, zbrush use two screens anyway.

also you can set ‘auto-hide’ mode for taskbar display.

Yeah, yeah my second monitor burned down a week ago. Looking for a replacement for some time with increasing of working space. And about autohide taskbar in windows i know, but this is boring.

I’m sure)

if you are too bored have a fun:

make max window always on top

get a size of screen

and set size of max window as a screen size

1 Reply
(@blyskawka)
Joined: 2 years ago

Posts: 0
global User32
fn CreateUser32Assembly =
(
source = ""
source += "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "class User32
"
source += "{
"
source += " [DllImport(\"user32.dll\")]
"
source += " public static extern bool SetWindowPos(Int64 hWnd, int hWndArg, int Left, int Top, int Width, int Height, int hWndFlags);
"
source += "}
"

csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

compilerParams.GenerateInMemory = on
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly.CreateInstance "User32"
)
User32 = CreateUser32Assembly()
fn showTopmost name act:on = if (hwnd = windows.getChildHWND 0 name) != undefined do 
(
HWND_TOPMOST = -1
HWND_NOTOPMOST = -2

User32.setWindowPos hwnd[1] (if act then HWND_TOPMOST else HWND_NOTOPMOST) 0 0 0 0 0x3 -- (SWP_NOSIZE = 0x1, SWP_NOMOVE = 0x2)
act
)
/*
showTopmost "MAXScript Listener" act:on
showTopmost "MAXScript Listener" act:off

This works for child window

fn showTopmost  act:on = if (hwnd = windows.getMAXHWND() ) != undefined do 
(
	HWND_TOPMOST 	= -1
	HWND_NOTOPMOST 	= -2
	setWindowPos hwnd[1] (if act then HWND_TOPMOST else HWND_NOTOPMOST) 0 0 0 0 0x3
	act
)
showTopmost  act:on

Why this not works for main window?

-- Error occurred in showTopmost(); filename: ; position: 146; line: 5
--  Frame:
--   act: true
--   setWindowPos: undefined
--   HWND_TOPMOST: -1
--   HWND_NOTOPMOST: -2
--   hwnd: 1968606P
-- Type error: Call needs function or class, got: undefined

somebody?

global User32
fn CreateUser32Assembly =
(
source = ""
source += "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "class User32
"
source += "{
"
source += " [DllImport(\"user32.dll\")]
"
source += " public static extern bool SetWindowPos(Int64 hWnd, int hWndArg, int Left, int Top, int Width, int Height, int hWndFlags);
"
source += "}
"

csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

compilerParams.GenerateInMemory = on
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly.CreateInstance "User32"
)
User32 = CreateUser32Assembly()



fn showTopmost  act:on = if (hwnd = windows.getMAXHWND() ) != undefined do 
(
	HWND_TOPMOST 	= -1
	HWND_NOTOPMOST 	= -2
	User32.setWindowPos  hwnd (if act then HWND_TOPMOST else HWND_NOTOPMOST) 0 0 0 0 0x3
	act
)
showTopmost  act:on

Yeah, now Max is ontop :buttrock:
How to maximize them for all screen?

yes… it’s almost identical to what i showed http://forums.cgsociety.org/showpost.php?p=7177985&postcount=5

now is a full-screen… you have to add size and remove SWP_NOSIZE flag with using the same function.
screen size is:

SystemInformation.VirtualScreen.Width   
SystemInformation.VirtualScreen.Height

that’s it

ah… i forgot… you have also to remove a border. but there is an example i’ve posted here. it was about how to do it.

1 Reply
(@blyskawka)
Joined: 2 years ago

Posts: 0

Ok thanks! Сurrently reading themes with your posts,hopefully shall understand something

here is the right answer: http://stackoverflow.com/questions/2398746/removing-window-border

‘GetWindowLong’ is a key word for search on this forum

1 Reply
(@blyskawka)
Joined: 2 years ago

Posts: 0

Ok, but first nomove nosize?

fn showTopmost  act:on = if (hwnd = windows.getMAXHWND() ) != undefined do 
(
	HWND_TOPMOST 	= -1
	HWND_NOTOPMOST 	= -2
	SWP_NOSIZE = 0x0001
	SWP_NOMOVE = 0x0002

	User32.setWindowPos  hwnd (if act then HWND_TOPMOST SWP_NOSIZE SWP_NOMOVE else HWND_NOTOPMOST) 0 0 0 0 0x3   
	
	act
)
showTopmost  act:on
showTopmost()
-- Error occurred in showTopmost(); filename: ; position: 244; line: 8
--  Frame:
--   hwnd: 658718P
--   act: true
--   HWND_TOPMOST: -1
--   HWND_NOTOPMOST: -2
--   SWP_NOSIZE: 1
--   SWP_NOMOVE: 2
-- Type error: Call needs function or class, got: -1

What is wrong? Sorry maybe for stupid questions

 global User32Assembly
   fn CreateUser32Assembly forceRecompile:on =
   (
  	 if forceRecompile or not iskindof ::User32Assembly dotnetobject or (::User32Assembly.GetType()).name != "Assembly" do
  	 (
  		 source = "using System;
"
  		 source += "using System.Runtime.InteropServices;
"
  		 source += "class User32
"
  		 source += "{
"
  		 source += " [DllImport(\"User32.DLL\", EntryPoint=\"GetWindowLong\")]
"
  		 source += " public static extern Int32 GetWindowLong(IntPtr hWnd, Int32 index);
"
  		 source += " [DllImport(\"User32.DLL\", EntryPoint=\"SetWindowLong\")]
"
  		 source += " public static extern Int32 SetWindowLong(IntPtr hWnd, Int32 index, Int32 newVal);
"
  		 source += " [DllImport(\"user32.dll\", EntryPoint=\"SetWindowPos\")]
"
  		 source += " public static extern bool SetWindowPos(IntPtr hWnd, int hWndArg, int Left, int Top, int Width, int Height, int hWndFlags);
"
  		 source += " [DllImport(\"user32.dll\", CharSet=CharSet.Auto)]
"
  		 source += " public static extern IntPtr GetParent(IntPtr hWnd);
"
  		 source += " [DllImport(\"user32.dll\")]
"
  		 source += " public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
"
  		 source += "	[DllImport(\"user32.dll\", EntryPoint=\"GetWindowRect\")]
"
  		 source += "	static extern bool GetWindowRect(IntPtr hWnd, out POS rect);
"
  		 source += "	[DllImport(\"user32.dll\", EntryPoint=\"GetClientRect\")]
"
  		 source += "	static extern bool GetClientRect(IntPtr hWnd, out POS rect);
"
  		 source += "	public struct POS
"
  		 source += "	{
"
  		 source += "		public int Left;
"
  		 source += "		public int Top;
"
  		 source += "		public int Right;
"
  		 source += "		public int Bottom;
"
  		 source += "	}
"
  		 source += "	public int[] GetWindowPosAndSize(IntPtr hWnd)
"
  		 source += "	{
"
  		 source += "		POS rect;
"
  		 source += "		if ( GetWindowRect(hWnd, out rect) )
"
  		 source += "		{
"
  		 source += "			return new int[] { rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top };
"
  		 source += "		}
"
  		 source += "		return null;
"
  		 source += "	}
"
  		 source += "	public int[] GetClientPosAndSize(IntPtr hWnd)
"
  		 source += "	{
"
  		 source += "		POS rect;
"
  		 source += "		if ( GetClientRect(hWnd, out rect) )
"
  		 source += "		{
"
  		 source += "			return new int[] { rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top };
"
  		 source += "		}
"
  		 source += "		return null;
"
  		 source += "	}
"
  		 source += "	[DllImport(\"user32.dll\")]
"
  		 source += "	static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, uint flags);
"
  		 source += "	public bool RedrawAllWindow(IntPtr hWnd, uint flags) { return RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero, flags); }
"
  		 source += "}
"
   
  		 csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
  		 compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
  						 
  		 compilerParams.GenerateInMemory = true
  		 compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
  		 ::User32Assembly = compilerResults.CompiledAssembly
  	 )
  	 ::User32Assembly.CreateInstance "User32"
   )
  
  	global User32 = CreateUser32Assembly()
fn showTopmost  act:on = if (hwnd = windows.getMAXHWND() ) != undefined do 
(
	HWND_TOPMOST 	= -1
	HWND_NOTOPMOST 	= -2
	GWL_STYLE 		= -16 
	WS_BORDER		= 0x00800000
	WS_DLGFRAME		= 0x00400000
	WS_THICKFRAME   = 0x00040000
   
	SWP_NOSIZE 		= 0x0001
	SWP_NOMOVE 		= 0x0002
	SWP_NOZORDER 	= 0x0004
	SWP_ASYNCWINDOWPOS = 0x4000
 
  	
  	FULL_REDRAW 	= 0x0185


	User32.GetWindowLong hwnd GWL_STYLE
	User32.setWindowPos  hwnd (if act then HWND_TOPMOST else HWND_NOTOPMOST) 0 0 0 0 0x3  flag:(SWP_NOSIZE = 0x1   SWP_NOMOVE = 0x2) 
	User32.RedrawAllWindow hwnd 0x185
	
	act
)
showTopmost  act:on

Im on the right way?
If i understood correctly now i must delete borders and then maximize window?

I think i need this?

  			f = ::User32.GetWindowLong hwnd GWL_STYLE
  			f = bit.xor f (WS_BORDER + WS_DLGFRAME + WS_THICKFRAME)

Not sure how to write it correctly

Page 1 / 2