Shame on me.
Yes, I realize that F goes out of scope.
I've now declared F outside the sub as Public Shared F as Form1
Also, I'm Hiding the form instead of Closing it.(I go e.Cancel=True and
Me.Hide in FormClosing event handler)
This solves the problem.
Thank you very much!
"Tony Tanzillo" wrote in message
news:5757549@discussion.autodesk.com...
Have you considered what happens to the
variable F when your sub finishes, and the
form is still visible?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
"Guido Rooms" wrote in message news:5757301@discussion.autodesk.com...
This is the command definition:
_
Public Shared Sub TESTMODELESS()
Dim F As New Form1
Application.ShowModelessDialog(F)
End Sub
On Form1, there is just one button with the following handler for its click
event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MessageBox.Show("Test")
End Sub
Now, when I click Button1, then close the resulting messagebox and after
that Form1 itself, AutoCAD loses focus and any other application open at
that moment becomes the foreground application.
If Form1 is shown as a modal dialog, the problem does not occur (contary to
what I wrote in my original post).
Greetings.
"Tony Tanzillo" wrote in message
news:5756862@discussion.autodesk.com...
Can you post an example showing this?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
"Guido Rooms" wrote in message news:5755989@discussion.autodesk.com...
When I use ShowModalDialog() or ShowModelessDialog() to display MyForm, and
MyForm in turn displays a modal dialog, then, when MyForm closes, AutoCAD
loses focus and whatever other application running at that time becomes the
foreground application. Using e.g.
ShowModelessDialog(Application.MainWindow, MyForm) does not help.
The problem also occurs when calling e.g. then MessageBox.Show() function
(with or without owner specified).
Thanks in advance for any help.
Guido Rooms.