Error when closing dialog with titlebar X-button

I have a little issue with a dialog. I always get an "unexpected method call" error if and only if I close the dialog using the X-button in the title bar. Closing the dialog with any close-button doesn't show that message. Here's the code that throws the error message:

If dlg.Control("combo1").value = 2 Then dlg.Control("edit2").visible = True dlg.Control("edit2").SelectRange 0,-1 If colIndex = False And Script.config.IndexColumn = False Then cmd.RunCommand("Set COLUMNSADD=index(0)") End If Else dlg.Control("edit2").visible = False If colIndex = False And Script.config.IndexColumn = False Then cmd.RunCommand("Set COLUMNSREMOVE=index") End If End IfDepending on the state of combo1 the error refers to line 2 or 8. I tried to enclose the whole thing in an "If dlg.result = 0 Then" clause but this didn't work because hide/show the Column/Control didn't work correctly.
How can I avoid that error?

If the window's been closed you can't make changes to controls in the window (because they no longer exist).

I know and didn't want to do that but it seems my Script wants to hide the controls when I close it with the X-Button. What I tried was an If-clause If Not dlg.result = 0 Then (I forgot the Not in my last post). Not a big deal but I don't like error messages. :smiley:

I'm now getting this error message for the very first line of the dialog message loop. The message doesn't appear when closing the dialog with a close button that does If dlg.result =0 Then. I put the line If msg.result = 0 Then exit do right after the line Set Msg = Dlg.GetMsg() but it didn't help. Closing the dialog with the X-button doesn't seem to output 0 to dialog/Msg so the message loop doesn't exit and the code after If dlg.result = 0 Then (clear some filters) isn't executed. I have to add On error resume next to avoid this but that's not a good solution.
Please have a look into this.

Can you post the script and dialog? (or a cut down version that reproduces the problem)

I don't want to publish the script right now. I'll send it to

Thanks for sending the script, I was able to reproduce the problem and we'll have a fix for it in the next beta.

Great! Thanks for fixing this.

Everything's fine now with this issue. Thanks again.