Weird Unhandled Exception

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

Why is it that setting the current (open) form's text to "" does not
remove it from the running programs listing in WM 2003. I know forms
are not enumerated, that's why everyone on this board says set the
text to "", yet it doesn't work, why?

Here's an example of what I'm doing...On this form on the button
click:

Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnEnter.Click
frmLoginHelper.Instance().Text = "My App" 'Set title bar text
frmLoginHelper.Instance().ShowDialog() 'Show form
Me.Text = ""
End Sub

So what am I doing wrong, or is something buggy?

Thanks
 
Sorry about the message subject...I'm not getting any errors, but my
problem as I described it is accurate, just no errors.
 
When are you checking the running list? If it is while the
frmLoginHelper.Instance is shown then move the Me.Text="" before the
ShowDialog call.

Cheers
Daniel
 
So what shows up in Running Programs? It enumerates the captions of
top-level Windows. If your caption is empty, what exactly is displaying?

-Chris
 
Exactly what shouldn't, the captions of my windows, over and over, one
for each one that's open, yet I have set the text in everyone to an
empty string. This exact same block of code (only in C#) in a
previous C# project worked just fine, but not here for some reason.
 
My point is the fact that the captions show up in Running Programs tells me
that you're not getting them changed. Looking at your code I see you change
the caption after calling ShowDialog.

You're aware that ShowDialog is blocking, right? So the Caption isn't going
to get changed until *after* the form you display with ShowDialog is
dismissed. This means that, based on your code, I would expect to see the
caption on the dialog and the parent in Running Programs when the dialog is
up.

If you had simply placed a break point anywhere in the dialog's code, then
using the immediate window looked at the Text property for both the dialog
and the parent at that break point you would have seen this to be the case.

-Chris
 
In a related question, why is this menu code for exiting my
application, only disposing of the open form and showing the next form
underneath, shouldn't it be disposing of all forms when I call
Application.Exit()?

Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuExit.Click
Me.Dispose()
Application.Exit()
End Sub
 
rough guess.. try calling Application.Exit from your main form, this will
definitely exit all forms.
 
Depends. I'm guessing this is a modal form shown with ShowDialog? If so,
it may be directing to the wrong message pump. The reality is that I rarely
if ever use Application.Exit. When my app needs to end, I close the form
that holds the message pump, causing it to exit and the app then pops back
up the call stack to void Main, where it exits cleanly.

-Chris
 
Back
Top