Record some structure MaxScript

struct maxFormBuilderStruct
(
    
    theFrm = dotNetObject "MaxCustomControls.MaxForm"
    ,theBtn = dotNetObject "System.Windows.Forms.Button"
    ,fn theFunc = messageBox "123"
    
    ,on create do
    (
        DotNet.AddEventHandler this.theBtn "click" this.theFunc
        
        this.theFrm.controls.add this.theBtn
        this.theFrm.Show(theHwnd)
    )
)
--maxFormBuilderStruct()
------------------------------------------------------------

rollout maxFormBuilderRoll ""
(
    local theFrm = dotNetObject "MaxCustomControls.MaxForm"
    local theBtn = dotNetObject "System.Windows.Forms.Button"
    
    fn theFunc = messageBox "456"
    
    fn init =
    (
        DotNet.AddEventHandler theBtn "click" theFunc
        theFrm.controls.add theBtn
        theFrm.Show(theHwnd)
    )
)

--maxFormBuilderRoll.init()
------------------------------------------------------------
fn maxFormBuilderFunc = 
(
    local controls = #()
    local theFrm = dotNetObject "MaxCustomControls.MaxForm"; append controls theFrm
    local theBtn = dotNetObject "System.Windows.Forms.Button"; append controls theBtn
    theFrm.controls.add theBtn

    thePtr = DotNetObject "System.IntPtr" (windows.getMAXHWND())
    theHwnd = (dotNetObject "System.Windows.Forms.NativeWindow").FromHandle thePtr
    
    fn theFunc = messageBox "789"
    DotNet.AddEventHandler theBtn "click" theFunc
    
    theFrm.Show(theHwnd)
    return controls
)

--maxFormBuilderFunc()

Guess you like

Origin www.cnblogs.com/trykle/p/11974131.html