Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Questions/Problems with subclassing controls and forms
Message
From
05/08/2010 16:45:00
 
General information
Forum:
ASP.NET
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01475116
Message ID:
01475438
Views:
39
Hi Thomas,

>Form 2 has also a cmdexit-button and I expected it to close this form too. But what it does is, that it shows first
>the "Interface Base doexit"-msgbox, then the "Interface Button"-msgbox (which does not happen on Form1) but does
>not close the form.


The second message "Interface Button" would not display with your Form1 because the Form has already closed (since you execute DoExit() before the message), and since it's your main Form, the app ends without displaying it. So, that's normal behavior.

Off the top of my head, I could not think of any reason why your Form behaves this way, so I played around with it to see if I could duplicate your behavior. And no, I couldn't get it to fail ... it worked fine for me.

But, here's some food for thought. When you show a form with .ShowDialog(), the reference to that form is still there when the Form closes (the next statement after the .ShowDialog()), whereas when you open it with .Show(), execution continues after that and when you leave the click handler that launched the Form, the reference to that form is gone. Put a breakpoint after your .ShowDialog() (or .Show() when you tested it that way) to see what I mean. Now, that may or may not have anything to do with your problem ... but, if your Form2 is doing something else to remain visible even after it's closed, you'll still see it! I suspect this may be what's causing your problem and maybe that might give you a clue as to how to track it down.

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform