| 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 |
| |
| theHwnd = (dotNetObject "System.Windows.Forms.NativeWindow").FromHandle (DotNetObject "System.IntPtr" (windows.getMAXHWND())) |
| theFrm.Show(theHwnd) |
| ) |
| ) |
| -- maxFormBuilderStruct() |
| 注意:max2019初代版本,dotnet事件处理函数,如果是结构体内的,会被gc掉,事件函数需要一个全局函数 |
| 甚至,你无法将filein放在结构体的函数内 |
| ------------------------------------------------------------ |
| |
| 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 |
| |
| theHwnd = (dotNetObject "System.Windows.Forms.NativeWindow").FromHandle (DotNetObject "System.IntPtr" (windows.getMAXHWND())) |
| 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 |
| |
| fn theFunc = messageBox "789" |
| DotNet.AddEventHandler theBtn "click" theFunc |
| |
| theHwnd = (dotNetObject "System.Windows.Forms.NativeWindow").FromHandle (DotNetObject "System.IntPtr" (windows.getMAXHWND())) |
| theFrm.Show(theHwnd) |
| return controls |
| ) |
| |
| -- maxFormBuilderFunc() |
| |
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步