The CreateDialog function lets you turn an existing rollout definition into a floating Dialog.
Other than a RolloutFloater, which is a container of one or more rollouts, a Dialog is a special display form of the rollout itself.
It provides advanced features like a modal display option, background bitmap display, and mouse event handlers.
The syntax for creating dialogs is:
CreateDialog <Rollout> [<width> <height> <position_x> <position_y>]\
[pos:<Point2>] [width:<integer>] [height:<integer>] \
[bgcolor:<color>] [fgcolor:<color>] \
[bitmap:<bitmap>] {bmpstyle:<bmpstyle> \
[menu:<RCMenu>] [style:<array>] [modal:<boolean>] \
[escapeEnable:<boolean>] [lockHeight:<boolean>] [lockWidth:<boolean>] \
[autoLayoutOnResize:<boolean>] [parent:<HWND>]
When the optional modal:
keyword is set to True, the dialog ignores all user interactions except those within the dialog.
Call DestroyDialog()
to close it, presumably in a scripted OK button.
The user can also close a modal scripted dialog by hitting the Escape key as long as escapeEnable
keyword is set to False or not supplied.
When the optional escapeEnable
keyword is set to True, MAXScript escape checker will be disabled for the dialog, preventing the Interrupted message from appearing.
If the optional lockHeight
keyword is True , the height of the dialog cannot be interactively changed.
If the optional lockWidth
keyword is True , the width of the dialog cannot be interactively changed.
Parameters:
<Rollout>
The rollout definition to create the dialog form.
pos:<Point2> -- default:dialog will center within MAX.
Placement of the upper left corner of the dialog relative to the upper left corner of the screen.
width:<integer> -- default:200
Width of the dialog box.
height:<integer> -- default:dynamic on control extents
Height of the dialog box.
bgcolor:<color> -- default:(<system button color>)
Background color of the dialog.
fgcolor:<color> -- default:(color 0 0 0)
Forground color of the dialog (static text color)
bitmap:<bitmap> -- default:undefined
Background bitmap for the dialog.
bmpstyle:<key> -- default:#bmp_center
The way that the background bitmap is displayed.
It can be one of the following:
#bmp_center #bmp_tile #bmp_stretch
menu:<RCMenu> -- default:undefined
Menu that appears in the title bar area of the dialog.
style:<array> -- default:#(#style_titlebar, #style_border, #style_sysmenu)
Array of style flags that can be one or more of the following:
#style_border:
Creates a window with a double border, but no title.
#style_titlebar:
Creates a dialog with a title bar.
#style_toolwindow:
Creates a tool window, which has a title bar and is intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font.
#style_resizing:
Creates a window with a thick frame that can be used to size the window.
#style_minimizebox:
Creates a window that has a minimize button.
#style_maximizebox:
Creates a window that has a maximize button.
#style_sysmenu:
Creates a window that has a window menu in its title bar.
#style_sunkenedge:
Specifies that a window has a 3D look in the form of a border with a sunken edge.
#style_titlebar
, #style_border
, and #style_sysmenu
are used.autoLayoutOnResize:<boolean>]
If set to true, when the dialog is resized either in the UI or by a script, the layout of the controls in the rollout is updated if autoLayoutOnResize:true was also specified for the rollout. Available in 3ds Max 2019 and higher.
The default is false.
parent:<HWND> -- default:<MAX_HWND>
Parents the dialog to the specified window.
When not supplied, the parent is set to the 3ds Max Window Handle, causing the dialog to minimize/maximize with the 3ds Max UI.
When set to a valid HWND, the dialog becomes a Child dialog of the specified Parent and minimizes/restores with it. It always stays in front of the Parent even when the Parent has focus.
As the rollout class provides a .hwnd
property, it is easy to parent one dialog to another:
FOR EXAMPLE:
rollout parent_dialog "Parent" --define a rollout and create a dialog ( label lbl_test "Parent" on parent_dialog close do print "PARENT Closed!" ) createDialog parent_dialog pos:[100,100] style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox) rollout child_dialog "Test2" --define another rollout ( label lbl_test "Child" on child_dialog close do print "CHILD Closed!" ) --Create a dialog from the second rollout and pass the .HWND of the first dialog as the parent: argument: createDialog child_dialog pos:[200,130] parent:parent_dialog.hwnd style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox) setFocus parent_dialog --set focus on the Parent dialog - the Child will still be drawn in front of it!
At this point, minimizing and restoring the Parent dialog causes the Child dialog to follow. When the Parent dialog is minimized, the Child is not shown at all.
Closing the Parent dialog automatically closes the Child, but it will NOT invoke the
on close do
handler of the Child dialog.
.parent
property, only a parameter. It is not possible to dynamically re-parent an already created dialog.EXAMPLE:
( sme.Open() --Open the SME theParent = windows.getChildHWND 0 "Slate Material Editor" --get the HWND of the SME rollout sme_toolbox_rollout "SME Toolbox" ( button btn_nextMap "UP One Level" width:150 on btn_nextMap pressed do ( theObj = sme.GetMtlInParamEditor() --get the node from the parameter panel if theObj != undefined do --if there is a valid node, get its dependents ( local theDeps = for m in refs.dependents theObj where isKindOf m TextureMap or isKindOf m Material collect m if theDeps.count > 0 do sme.SetMtlInParamEditor theDeps[1] --if there were any, select the first one ) ) ) createDialog sme_toolbox_rollout parent:theParent[1] --create a dialog as child of the SME )
The new dialog stays in front of the SME and minimizes/restores with it, but it does not close if the SME is closed.
Events:
on <Rollout> open do
Called when the dialog is opening.
on <Rollout> close do
Called when the dialog is closing.
on <Rollout> moved <Point2> do
Called when the dialog is being moved.
on <Rollout> resized <Point2> do
Called when the dialog is being resized.
on <Rollout> mousemove <Point2> do
Called when the mouse is being moved within the dialogs client area.
on <Rollout> lbuttondown <Point2> do
Called when the left mouse button is pressed down within the dialog.
on <Rollout> lbuttonup <Point2> do
Called when the left mouse button is released.
on <Rollout> lbuttondblclk <Point2> do
Called when the left mouse button is double clicked within the dialog.
on <Rollout> mbuttondown <Point2> do
Called when the middle mouse button is pressed down within the dialog.
on <Rollout> mbuttonup <Point2> do
Called when the middle mouse button is released.
on <Rollout> mbuttondblclk <Point2> do
Called when the middle mouse button is double clicked within the dialog.
on <Rollout> rbuttondown <Point2> do
Called when the right mouse button is pressed down within the dialog.
on <Rollout> rbuttonup <Point2> do
Called when the right mouse button is released.
on <Rollout> rbuttondblclk <Point2> do
Called when the right mouse button is double clicked within the dialog.
The <Point2>
value passed to the event handlers is the position of the mouse within the dialog client window. A value of [0,0] corresponds to the top left corner of the client window.
Associated Methods
<Point2>GetDialogPos <Rollout> [removeUIScaling: <boolean>]
<Point2>GetDialogSize <Rollout> [removeUIScaling: <boolean>]
Returns the position or size of the Dialog built from the rollout relative to the upper left corner of the screen in Point2 format.
removeUIScaling
: Removes UI scaling applied by high-DPI displays if true. The default is true.
SetDialogPos <Rollout> <Point2> [applyUIScaling: <boolean>]
Sets the position of the Dialog built from the rollout. The position is relative to the upper left corner of the screen.
<Rollout>:
The rollout used to build the Dialog to set the position of.
<Point2>:
Position applied to the Dialog.
applyUIScaling
: Applies UI scaling to the position on high-DPI displays if true. Available in 3ds Max 2019 and higher. The default is true.
SetDialogSize <Rollout> <Point2> [applyUIScaling: <boolean>]
Sets the size of the Dialog built from the rollout. Available in 3ds Max 2019 and higher.
<Rollout>:
The rollout used to build the Dialog to set the size of.
<Point2>:
Size to applied to the Dialog.
applyUIScaling
: Applies UI scaling to the size on high-DPI displays if true. The default is true.
SetDialogBitmap <rollout> <bitmap>
Sets the bitmap background for the dialog associated with the rollout. If the rollout is not in a dialog, no action is taken. A value of 'undefined' for the bitmap clears the current bitmap.
<bitmap>GetDialogBitmap <rollout>
Gets the bitmap background for the dialog associated with the rollout. If the rollout is not in a dialog, 'undefined' is returned