Notifications
Clear all

[Closed] Did you know that?

only today i found undocumented optional argument for createDialog function. is parent
if you pass hwnd of any dialog (form, rollout floater, etc.) the created dialog becomes a child window of a parent dialog. it minimizes with the parent, hides/shows with the parent, closes with the parent, and always stays on top of the parent.
check yourself:


try(destroydialog parentDialog) catch()
rollout parentDialog "Parent Dialog" width:200
(
	label lb "PARENT" align:#center
)
createdialog parentDialog style:#(#style_titlebar, #style_sysmenu, #style_minimizebox, #style_maximizebox)

rollout childDialog "Child Dialog" width:200
(
	label lb "CHILD" align:#center
)
createdialog childDialog parent:(windows.getchildhwnd 0 parentDialog.title)[1] pos:(getdialogpos parentDialog + [80,80])

is it hard to add this useful thing to the documentation?

14 Replies

It is in the docs for 2014, marked as new:

Link

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s in since max 2010 for sure. i don’t have earlier versions to check.

I tested the Denis code and it works with max9 and max2009.

Yes! I knew something Denis didn’t! Strange I thought the moon was slightly blue last night…

What I’ve used it for is for linking to existing max windows so that it always floats on top, as you can get the hWnd for any max window, it won’t close automatically with the non-maxscript window but it sits on top nicely

but did you know that cui.registerDialogBar has the same hidden argument too ;):


try(cui.UnregisterDialogBar TVChildDialog) catch()
try(destroydialog TVChildDialog) catch()
rollout TVChildDialog "TV Extras" width:120
(
	local tv
	group "Extras: " 
	(
		button assign_bt "Assign Dialog" width:100 align:#center tooltip:"Open the assign controller dialog"
		button delkeys_bt "Delete Keys" width:100 align:#center tooltip:"Delete All Keys"
	)
	on assign_bt pressed do if (tv = trackviews.current) != undefined do 
	(
		if tv.canAssignController() do tv.assignControllerDialog()
	)
	on delkeys_bt pressed do if (tv = trackviews.current) != undefined do undo "Delete All Keys" on
	(
		deletekeys (for k=1 to tv.numSelTracks() where iscontroller (t = tv.getSelected k) and numkeys t > 0 collect t)
	)
)
trackviews.open "Curve Editor"
createdialog TVChildDialog
cui.registerDialogBar TVChildDialog parent:trackviews.current.ui.hwnd maxSize:[126,90]
cui.DockDialogBar TVChildDialog #cui_dock_left

Hmmm… very interesting, shame you can’t dock a window on the Render Scene Dialog, that’s what I really want to do!

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

do you mean Render Frame Window? what do you want to dock?

And it doesn’t work either with the Compact Material Editor or Slate, or Particle Flow…

these windows doesn’t support registered dialog bars. today i know only max itself and trackview windows support it.

i can continue your list… Unwrap UVW Editor

RenderSceneDialog.open()

I want to dock a dialog on to this window so I can have a set of tools next to it for setting up render elements etc…

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

probably i can find a trick… let me think.

(@denist)
Joined: 11 months ago

Posts: 0

here is some trick:


  global _user32
  fn create_user32Assembly forceRecompile:on = if forceRecompile or not iskindof ::_user32Assembly dotnetobject do
  (
  	source  = "using System;
"
  	source += "using System.Runtime.InteropServices;
"
  	source += "class User32
"
  	source += "{
"
  	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\")]
"
  	source += " 	public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
"
  	source += "}
"
  
  	csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
  	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
  
  	compilerParams.ReferencedAssemblies.AddRange #("System.dll")
  
  	compilerParams.GenerateInMemory = true
  	compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
  	
  	_user32 = (compilerResults.CompiledAssembly).CreateInstance "User32"
  )
  create_user32Assembly()
  
  try(destroydialog RenderSetupChild) catch()
  rollout RenderSetupChild "Render Setup Child" width:347 height:54
  (
  	local d_hwnd = if d_hwnd != undefined do d_hwnd
  	local c_ptr, p_ptr
  	
  	groupbox gb pos:[4,-3] width:339 height:56
  		checkbox undoable_ch "Undoable" checked:on pos:[20,9]
  		button delete_bt "Delete All Render Elements" pos:[11,28] width:324
  
  	checkbutton display_bt width:14 height:14 pos:[1,1] tooltip:"Open Extras"
  
  	on delete_bt pressed do undo "Delete Render Elements" undoable_ch.state
  	(
  		rem = maxOps.GetCurRenderElementMgr()
  		if undoable_ch.state then 
  		(
  			for k = rem.NumRenderElements() - 1 to 0 by -1 do rem.RemoveRenderElement (rem.GetRenderElement k)
  		)
  		else rem.RemoveAllRenderElements() -- don't use because it's not undoable
  	)
  	on display_bt changed state do 
  	(
  		setfocus undoable_ch
  		if state then _user32.SetWindowPos c_ptr 0 0 0 347 54 2
  		else _user32.SetWindowPos c_ptr 0 0 0 15 15 0
  	)
  	on RenderSetupChild open do if (uiaccessor.iswindow d_hwnd) do
  	(
  		c_ptr = dotnetobject "IntPtr" (windows.getchildhwnd 0 RenderSetupChild.title)[1]
  		p_ptr = dotnetobject "IntPtr" d_hwnd
  
  		_user32.SetParent c_ptr p_ptr
  		_user32.SetWindowPos c_ptr 0 0 0 15 15 0
  	)
  )
  
  RenderSceneDialog.open()
  hwnd = for hwnd in uiaccessor.getpopupdialogs() where matchpattern ((uiaccessor.getwindowtext hwnd) as string) pattern:"Render Setup*" do exit with hwnd 
  RenderSetupChild.d_hwnd = hwnd
  createdialog RenderSetupChild style:#()
  
Page 1 / 2