With this code, see at the very bottom. When the modal property of the dialog is set to true it crashes max and when it's set to false it doesn't.
I believe this is something to do with the .NET buttons and the event handler. But it would be a great help if someone knew how to fix this to get the dialog as a modal one without it crashing.
Having the buttons here in a `FlowLayoutPanel` is required here as the main script I'm writing requires the buttons to get their invisible property turned on or off.
The 3dsMax version I'm using is 2020.
try destroyDialog RollsRoyce catch()
rollout RollsRoyce "" width:400 height:90
(
local btnH = 22
dotNetControl panelVisibleFix "FlowLayoutPanel" width:RollsRoyce.width height:btnH --pos:[0,0]
button btn_test "Regular Button" width:(RollsRoyce.width/2) height:btnH
fn dnDrawingColorFromColorMan name = (clr = (colorMan.getColor name) * 255.0 ; (dotNetClass "System.Drawing.Color").fromARGB clr.x clr.y clr.z)
fn makeNETBtn width height text visible:on =
(
local btn = dotNetObject "Button"
btn.Text = text
btn.Width = width
btn.Margin = dotNetObject "Padding" 0 0 0 0
btn.Height = height
btn.FlatStyle = btn.FlatStyle.System
btn.Visible = visible
btn
)
fn Btn1Pressed_fn = print "Button 1 Pressed..."
fn Btn2Pressed_fn = print "Button 2 Pressed..."
on RollsRoyce open do
(
local btnW = RollsRoyce.width / 2
local btn1 = makeNETBtn btnW btnH ".NET &Button 1" visible:off
local btn2 = makeNETBtn btnW btnH ".NET Button 2" visible:off
panelVisibleFix.backColor = dnDrawingColorFromColorMan #background
panelVisibleFix.Controls.AddRange #(btn1, btn2)
panelVisibleFix.pos = [0,0]
btn1.visible = on
btn2.visible = on
dotNet.addEventHandler btn1 "Click" Btn1Pressed_fn
dotNet.addEventHandler btn2 "Click" Btn2Pressed_fn
btn1.focus()
)
)
createDialog RollsRoyce modal:true -- Setting modal to true crashes Max
-- createDialog RollsRoyce modal:false -- This doesn't crash Max
By 3dwannab · 2021-09-28