CreateDialog

 

   

Creating User Interfaces - Quick Navigation

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 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>] \
[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 from.

   

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.

Can be one of the following:

#bmp_center #bmp_tile #bmp_stretch 

   

menu:<RCMenu> -- default:undefined 

Menu that will appear in the title bar area of the dialog.

   

style:<array> -- default:#(#style_titlebar, #style_border, #style_sysmenu) 

Array of style flags, 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.

NOTE:If the style keyword parameter is not specified, the default styles of #style_titlebar , #style_border , #style_sysmenu are used.

   

parent:<HWND> -- default:<MAX_HWND>

Parents the dialog to the specified window.

When not supplied, the parent will be 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 will become a Child dialog of the specified Parent and will minimize/restore with it, and will always stay in front of the Parent even when the Parent has focus.

Since 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 will cause the Child dialog to follow. When the Parent dialog is minimized, the Child will not be shown at all.

Closing the Parent dialog will automatically close the Child, too, but it will NOT invoke the on close do handler of the Child dialog!

NOTE:There is no .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 will stay in front of the SME and will minimize/restore with it, but it will 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 left mouse button is double clicked within the dialog.

   

on <Rollout> mbuttondown <Point2> do 

Called when 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 middle mouse button is double clicked within the dialog.

   

on <Rollout> rbuttondown <Point2> do 

Called when 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 right mouse button is double clicked within the dialog.

NOTE:

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. The top left corner of the dialog window

   

Associated Methods

<Point2>GetDialogPos <Rollout> 

Returns the position of the Dialog built from the rollout relative to the upper left corner of the screen in Point2 format.

   

SetDialogPos <Rollout> <Point2> 

Sets the position of the dialog built from the rollout relative to the upper left corner of the screen.

Rollout: The rollout used to build the Dialog.

Point2: Position where the Dialog is placed.

   

<Point2>GetDialogSize <rollout> 

Returns the size of the window's client area. Equivalent to point2 <rollout>.width <rollout>.heigh

   

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 will clear 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

See Also