Using DotNet Forms To Create MAXScript User Interfaces

new.gif NEW in 3ds Max 9: DotNet controls can not only be placed inside 3ds Max Dialogs and Rollouts, but they can also be used to generate user interfaces implemented completely using DotNet Forms.

In the following example, a DotNet Button is created and assigned to a DotNet Form including a custom function declared as event handler. Finally, the Form is displayed as a dialog by calling its .show() method.

?

Script:

(

fn whenButtonIsPressed a b =

(

format "Pressed from a DotNet Button\n"

format "Argument a (Form): <%> \n" (classof a)

format "Properties:\n"

showproperties a

format "Methods:\n"

showmethods a

format "Events:\n"

showevents a

format "\nArgument b (Button): <%> \n" (classof b)

format "Properties:\n"

showproperties b

format "Methods:\n"??

showmethods a

format "Events:\n"??

showevents a

)

--Create a DotNet Button

mButton = dotNetObject "System.Windows.Forms.Button"

mButton.text = "BIG DotNet Button"

mButton.size = dotNetObject "System.Drawing.Size" 160 160

mButton.location = dotNetObject "System.Drawing.Point" 60 60

?

--Create a DotNet Form

hForm = dotNetObject "System.Windows.Forms.Form"??

hForm.controls.add mButton --add the Button to the Form

hForm.topmost = true

--Add an Event Handler for the click event:

dotNet.addEventHandler mButton "click" whenButtonIsPressed

?

hForm.show() --show the Form with the Button

)

?

dotNet_UI_BigButton.gif

?

Output Of The Event Handler When Button Pressed:

Pressed from a DotNet Button

Argument a (Form):

Properties:

.AccessibilityObject : , read-only

.AccessibleDefaultActionDescription :

.AccessibleDescription :

.AccessibleName :

.AccessibleRole :

.AllowDrop :

.Anchor :

.AutoEllipsis :

.AutoScrollOffset :

.AutoSize :

.AutoSizeMode :

.BackColor :

.BackgroundImage :

.BackgroundImageLayout :

.BindingContext :

.Bottom : , read-only

.Bounds :

.CanFocus : , read-only

.CanSelect : , read-only

.Capture :

.CausesValidation :

.CheckForIllegalCrossThreadCalls : , static

.ClientRectangle : , read-only

.ClientSize :

.CompanyName : , read-only

.Container : , read-only

.ContainsFocus : , read-only

.ContextMenu :

.ContextMenuStrip :

.Controls : , read-only

.Created : , read-only

.Cursor :

.DataBindings : , read-only

.DefaultBackColor : , read-only, static

.DefaultFont : , read-only, static

.DefaultForeColor : , read-only, static

.DialogResult :

.DisplayRectangle : , read-only

.Disposing : , read-only

.Dock :

.Enabled :

.FlatAppearance : , read-only

.FlatStyle :

.Focused : , read-only

.Font :

.ForeColor :

.Handle : , read-only

.HasChildren : , read-only

.Height :

.Image :

.ImageAlign :

.ImageIndex :

.ImageKey :

.ImageList :

.ImeMode :

.InvokeRequired : , read-only

.IsAccessible :

.IsDisposed : , read-only

.IsHandleCreated : , read-only

.IsMirrored : , read-only

.LayoutEngine : , read-only

.Left :

.Location :

.Margin :

.MaximumSize :

.MinimumSize :

.ModifierKeys : , read-only, static

.MouseButtons : , read-only, static

.MousePosition : , read-only, static

.Name :

.Padding :

.Parent :

.PreferredSize : , read-only

.ProductName : , read-only

.ProductVersion : , read-only

.RecreatingHandle : , read-only

.Region :

.Right : , read-only

.RightToLeft :

.Site :

.Size :

.TabIndex :

.TabStop :

.Tag :

.Text :

.TextAlign :

.TextImageRelation :

.Top :

.TopLevelControl : , read-only

.UseCompatibleTextRendering :

.UseMnemonic :

.UseVisualStyleBackColor :

.UseWaitCursor :

.Visible :

.Width :

.WindowTarget :

Methods:

.BeginInvoke method

.BeginInvoke method args

.BringToFront()

.Contains ctl

.CreateControl()

.CreateGraphics()

.CreateObjRef requestedType

.Dispose()

.DoDragDrop data allowedEffects

.DrawToBitmap bitmap targetBounds

.EndInvoke asyncResult

.Equals obj

.[static]Equals objA objB

.FindForm()

.Focus()

.[static]FromChildHandle handle

.[static]FromHandle handle

.GetChildAtPoint pt

.GetChildAtPoint pt skipValue

.GetContainerControl()

.GetHashCode()

.GetLifetimeService()

.GetNextControl ctl forward

.GetPreferredSize proposedSize

.GetType()

.Hide()

.InitializeLifetimeService()

.Invalidate()

.Invalidate rc

.Invalidate region

.Invalidate invalidateChildren

.Invalidate region invalidateChildren

.Invalidate rc invalidateChildren

.Invoke method

.Invoke method args

.[static]IsKeyLocked keyVal

.[static]IsMnemonic charCode text

.NotifyDefault value

.PerformClick()

.PerformLayout()

.PerformLayout affectedControl affectedProperty

.PointToClient p

.PointToScreen p

.PreProcessControlMessage msg

.PreProcessMessage msg

.RectangleToClient r

.RectangleToScreen r

.[static]ReferenceEquals objA objB

.Refresh()

.ResetBackColor()

.ResetBindings()

.ResetCursor()

.ResetFont()

.ResetForeColor()

.ResetImeMode()

.ResetRightToLeft()

.ResetText()

.ResumeLayout()

.ResumeLayout performLayout

.Scale ratio

.Scale factor

.Scale dx dy

.Select()

.SelectNextControl ctl forward tabStopOnly nested wrap

.SendToBack()

.SetBounds x y width height

.SetBounds x y width height specified

.Show()

.SuspendLayout()

.ToString()

.Update()

Events:

on AutoSizeChanged e do ( ... )

on BackColorChanged e do ( ... )

on BackgroundImageChanged e do ( ... )

on BackgroundImageLayoutChanged e do ( ... )

on BindingContextChanged e do ( ... )

on CausesValidationChanged e do ( ... )

on ChangeUICues e do ( ... )

on Click e do ( ... )

on ClientSizeChanged e do ( ... )

on ContextMenuChanged e do ( ... )

on ContextMenuStripChanged e do ( ... )

on ControlAdded e do ( ... )

on ControlRemoved e do ( ... )

on CursorChanged e do ( ... )

on Disposed e do ( ... )

on DockChanged e do ( ... )

on DoubleClick e do ( ... )

on DragDrop e do ( ... )

on DragEnter e do ( ... )

on DragLeave e do ( ... )

on DragOver e do ( ... )

on EnabledChanged e do ( ... )

on Enter e do ( ... )

on FontChanged e do ( ... )

on ForeColorChanged e do ( ... )

on GiveFeedback e do ( ... )

on GotFocus e do ( ... )

on HandleCreated e do ( ... )

on HandleDestroyed e do ( ... )

on HelpRequested hlpevent do ( ... )

on ImeModeChanged e do ( ... )

on Invalidated e do ( ... )

on KeyDown e do ( ... )

on KeyPress e do ( ... )

on KeyUp e do ( ... )

on Layout e do ( ... )

on Leave e do ( ... )

on LocationChanged e do ( ... )

on LostFocus e do ( ... )

on MarginChanged e do ( ... )

on MouseCaptureChanged e do ( ... )

on MouseClick e do ( ... )

on MouseDoubleClick e do ( ... )

on MouseDown e do ( ... )

on MouseEnter e do ( ... )

on MouseHover e do ( ... )

on MouseLeave e do ( ... )

on MouseMove e do ( ... )

on MouseUp e do ( ... )

on MouseWheel e do ( ... )

on Move e do ( ... )

on PaddingChanged e do ( ... )

on Paint e do ( ... )

on ParentChanged e do ( ... )

on PreviewKeyDown e do ( ... )

on QueryAccessibilityHelp e do ( ... )

on QueryContinueDrag e do ( ... )

on RegionChanged e do ( ... )

on Resize e do ( ... )

on RightToLeftChanged e do ( ... )

on SizeChanged e do ( ... )

on StyleChanged e do ( ... )

on SystemColorsChanged e do ( ... )

on TabIndexChanged e do ( ... )

on TabStopChanged e do ( ... )

on TextChanged e do ( ... )

on Validated e do ( ... )

on Validating e do ( ... )

on VisibleChanged e do ( ... )

?

Argument b (Button):

Properties:

.Button : , read-only

.Clicks : , read-only

.Delta : , read-only

.Location : , read-only

.X : , read-only

.Y : , read-only

.Empty : , read-only, static

Methods:

.BeginInvoke method

.BeginInvoke method args

.BringToFront()

.Contains ctl

.CreateControl()

.CreateGraphics()

.CreateObjRef requestedType

.Dispose()

.DoDragDrop data allowedEffects

.DrawToBitmap bitmap targetBounds

.EndInvoke asyncResult

.Equals obj

.[static]Equals objA objB

.FindForm()

.Focus()

.[static]FromChildHandle handle

.[static]FromHandle handle

.GetChildAtPoint pt

.GetChildAtPoint pt skipValue

.GetContainerControl()

.GetHashCode()

.GetLifetimeService()

.GetNextControl ctl forward

.GetPreferredSize proposedSize

.GetType()

.Hide()

.InitializeLifetimeService()

.Invalidate()

.Invalidate rc

.Invalidate region

.Invalidate invalidateChildren

.Invalidate region invalidateChildren

.Invalidate rc invalidateChildren

.Invoke method

.Invoke method args

.[static]IsKeyLocked keyVal

.[static]IsMnemonic charCode text

.NotifyDefault value

.PerformClick()

.PerformLayout()

.PerformLayout affectedControl affectedProperty

.PointToClient p

.PointToScreen p

.PreProcessControlMessage msg

.PreProcessMessage msg

.RectangleToClient r

.RectangleToScreen r

.[static]ReferenceEquals objA objB

.Refresh()

.ResetBackColor()

.ResetBindings()

.ResetCursor()

.ResetFont()

.ResetForeColor()

.ResetImeMode()

.ResetRightToLeft()

.ResetText()

.ResumeLayout()

.ResumeLayout performLayout

.Scale ratio

.Scale factor

.Scale dx dy

.Select()

.SelectNextControl ctl forward tabStopOnly nested wrap

.SendToBack()

.SetBounds x y width height

.SetBounds x y width height specified

.Show()

.SuspendLayout()

.ToString()

.Update()

Events:

on AutoSizeChanged e do ( ... )

on BackColorChanged e do ( ... )

on BackgroundImageChanged e do ( ... )

on BackgroundImageLayoutChanged e do ( ... )

on BindingContextChanged e do ( ... )

on CausesValidationChanged e do ( ... )

on ChangeUICues e do ( ... )

on Click e do ( ... )

on ClientSizeChanged e do ( ... )

on ContextMenuChanged e do ( ... )

on ContextMenuStripChanged e do ( ... )

on ControlAdded e do ( ... )

on ControlRemoved e do ( ... )

on CursorChanged e do ( ... )

on Disposed e do ( ... )

on DockChanged e do ( ... )

on DoubleClick e do ( ... )

on DragDrop e do ( ... )

on DragEnter e do ( ... )

on DragLeave e do ( ... )

on DragOver e do ( ... )

on EnabledChanged e do ( ... )

on Enter e do ( ... )

on FontChanged e do ( ... )

on ForeColorChanged e do ( ... )

on GiveFeedback e do ( ... )

on GotFocus e do ( ... )

on HandleCreated e do ( ... )

on HandleDestroyed e do ( ... )

on HelpRequested hlpevent do ( ... )

on ImeModeChanged e do ( ... )

on Invalidated e do ( ... )

on KeyDown e do ( ... )

on KeyPress e do ( ... )

on KeyUp e do ( ... )

on Layout e do ( ... )

on Leave e do ( ... )

on LocationChanged e do ( ... )

on LostFocus e do ( ... )

on MarginChanged e do ( ... )

on MouseCaptureChanged e do ( ... )

on MouseClick e do ( ... )

on MouseDoubleClick e do ( ... )

on MouseDown e do ( ... )

on MouseEnter e do ( ... )

on MouseHover e do ( ... )

on MouseLeave e do ( ... )

on MouseMove e do ( ... )

on MouseUp e do ( ... )

on MouseWheel e do ( ... )

on Move e do ( ... )

on PaddingChanged e do ( ... )

on Paint e do ( ... )

on ParentChanged e do ( ... )

on PreviewKeyDown e do ( ... )

on QueryAccessibilityHelp e do ( ... )

on QueryContinueDrag e do ( ... )

on RegionChanged e do ( ... )

on Resize e do ( ... )

on RightToLeftChanged e do ( ... )

on SizeChanged e do ( ... )

on StyleChanged e do ( ... )

on SystemColorsChanged e do ( ... )

on TabIndexChanged e do ( ... )

on TabStopChanged e do ( ... )

on TextChanged e do ( ... )

on Validated e do ( ... )

on Validating e do ( ... )

on VisibleChanged e do ( ... )

?

Using this output, you can easily see what Properties, Methods and Events are available for each control and implement additional functionality to extend the script, change the appearance and behaviour of the DotNet controls and so on.

See also

DotNet In MAXScript