测试于2018,低版本应该不可用
![](https://img2020.cnblogs.com/blog/1077097/202003/1077097-20200311145904761-912448378.png)
rollout maxFormBuilderRoll ""
(
local theFrm = dotNetObject "MaxCustomControls.MaxForm"
local theBtn = dotNetObject "System.Windows.Forms.Button"
fn theFunc = messageBox "456"
fn init =
(
theBtn.Location = dotNetObject "System.Drawing.Point" 10 20
theBtn.Text = "按钮"
theBtn.Size = dotNetObject "System.Drawing.Size" 120 50
-- 让按钮使用max系统风格
theBtn.FlatStyle = (dotNetClass "System.Windows.Forms.FlatStyle").System
theFrm.Text = "窗口标题"
theFrm.controls.add theBtn
theFrm.StartPosition = (dotNetClass "System.Windows.Forms.FormStartPosition").CenterScreen
--theHwnd = (dotNetObject "System.Windows.Forms.NativeWindow").FromHandle (DotNetObject "System.IntPtr" (windows.getMAXHWND()))
--theFrm.Show(theHwnd)
--让maxForm停靠在max内
theFrm.ShowInFrame()
)
)
maxFormBuilderRoll.init()