In 3ds Max 9 and higher, the dotNetControl
class exposes the properties, methods, and events associated with the control via reflection.
Property access will take/get MAXScript number data types (widened as necessary), string, Boolean, dotNetControl, dotNetObject, and dotNetClass values. Property access will be via the normal property access specification [control.property] and get/setProperty.
Accessing a control method will create a dotNetMethod instance.
The event handlers for dotNetControl are handled in the same way as all UI controls use event handlers - the user defines a named scripted event handler in the rollout definition that is called when the event with the same name is fired on the control.
New methods are used to add and manage event handlers. These methods register and unregister callback functions to be called when the event is fired. The arguments passed back to the functions include the object, the event name, and the arguments passed by the event handler. See dotNet Struct Methods for details.
Constructor:
dotNetControl <name> <class_type_string> [{<property_name>:<value>}]
keyword arguments are applied to the control after the control is created and event handlers have been assigned, but before the control is added to the rollout.
Properties:
.focus
When set to true, the control will have focus. When set to false (default), the control will not have focus.
.enable
When set to false, the control will be disabled. When set to true (default), the control will be available.
Methods:
getProperty <dotNetControl> <prop name> [asDotNetObject:<boolean>]
Returns the value of the specified property.
If asDotNetObject
is false (the default) the value will converted to a native MAXScript value if possible; if true, the value will always be returned as a dotNetControl or dotNetObject value.
setProperty <dotNetControl> <prop name> <value>
Sets the value of the specified property. If the value specified is a native MAXScript value, it will be converted to the proper DotNet value if possible.
getPropNames <dotNetControl> [showStaticOnly:<boolean>] [declaredOnTypeOnly:<boolean>]
Returns an array of property names exposed by the control.
If showStaticOnly
is true (the default), only static properties are shown; if false both static and instance properties are shown.
If declaredOnTypeOnly
is true, only properties declared on the specified control are shown; if false (the default) properties on the control and the classes it derives from are shown.
The results of this method are sorted by name. The properties returned actually contain two different things in terms of DotNet- properties and fields. The properties are shown first in sorted order, then the fields are shown in sorted order.
showProperties <dotNetControl> ["prop_pat"] [to:<stream>] [showStaticOnly:<boolean>] [showMethods:<boolean>] [showAttributes:<boolean>] [declaredOnTypeOnly:<boolean>]
Displays the properties exposed by the control whose name matches the property pattern.
If to
is not specified, the output goes to Listerner, otherwise the output goes to the specified stream.
If showStaticOnly
is true (the default), only static properties are shown; if false both static and instance properties are shown.
If showMethods
is true, the signature of the get and set methods (if any) are shown; defaults to false.
If showAttributes
is true, the attributes associated with the property are shown; defaults to false.
If declaredOnTypeOnly
is true, only properties declared on the specified control are shown; if false (the default) properties on the control and the classes it derives from are shown.
The results of this method are sorted by name. The properties returned actually contain two different things in terms of DotNet - properties and fields. The properties are shown first in sorted order, then the fields are shown in sorted order.
showMethods <dotNetControl> ["prop_pat"] [to:<stream>] [showStaticOnly:<boolean>] [showSpecial:<boolean>] [showAttributes:<boolean>] [declaredOnTypeOnly:<boolean>]
Displays the methods exposed by the control whose name matches the property pattern.
If to
is not specified, the output goes to Listerner, otherwise the output goes to the specified stream.
If showStaticOnly
is true (the default), only static properties are shown; if false both static and instance properties are shown.
If showSpecial
is true, methods that are not normally called by the user (such as a method to set a property value or to invoke an event handler) are shown; defaults to false.
If showAttributes
is true, the attributes associated with the property are shown; defaults to false.
If declaredOnTypeOnly
is true, only properties declared on the specified control are shown; if false (the default) properties on the control and the classes it derives from are shown.
The results are sorted by name. Secondary sort is performed based on the number of parameters.
showEvents <dotNetControl> ["prop_pat"] [to:<stream>] [showStaticOnly:<boolean>] [declaredOnTypeOnly:<boolean>]
Displays the events exposed by the control whose name matches the property pattern.
If to
is not specified, the output goes to Listerner, otherwise the output goes to the specified stream.
If showStaticOnly
is true (the default), only static properties are shown; if false both static and instance properties are shown.
If declaredOnTypeOnly
is true, only properties declared on the specified control are shown; if false (the default) properties on the control and the classes it derives from are shown.
The results are sorted by name.
dotNet.showConstructors<dotNetClass> [to:<stream>]
Displays the constructors exposed by the control.
If to
is not specified, the output goes to Listerner, otherwise the output goes to the specified stream.
DotNet controls can be created by the class name of the control.
EXAMPLE
dotNetControl f1 "System.Windows.Forms.MonthCalendar" align:#left height:180
To create a class instance, DotNet needs more than just this information, it also needs the assembly info in the constructor string. The following shows the full string needed, and will also be valid:
EXAMPLE
dotNetControl f1 "System.Windows.Forms.MonthCalendar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" align:#left height:180
In most cases, the user doesn't care about the assembly version, and just wants to specify the class name. The MAXScript UI control wrapper will try to create the control using the specified class name, and if the control cannot be created it will append the "System.Windows.Forms" assembly info to the class name and try again.
If the class name specified still cannot be resolved, the class name will be prepended with "System." and another attempt will be made. Thus, this will be valid:
EXAMPLE
dotNetControl f1 "Windows.Forms.MonthCalendar" align:#left height:180
If the class name still cannot be resolved, the class name will be prepended with "System.Windows.Forms." and another attempt will be made. Thus, this will be valid:
EXAMPLE
dotNetControl f1 "MonthCalendar" align:#left height:180