OT: Dialog and windows forms

M

Marina

Hi,

I'm opening a dialog in my application. If then I switch to another
application (or if the dialog popped up while I was using another
application), the dialog is often behind the main form, but I can't get to
it. I can't do anything with the main form (because the dialog is open),
but I can't bring focus back to the dialog. I have to use Alt +Tab, to be
able to select it, which then gives the dialog focus again, so I can close
it.

But if I didn't do that, it just seems like the application is not
responsive. If I was in another application when the dialog popped up, you
can't even tell there was a dialog, so it just looks like the app froze.
When in reality doing the Alt+Tab, allows you to select the dialog.

Is there any way to make sure the dialog is always going to be on top of the
main form? It's being show using ShowDialog.
 
M

Marina

Looks like calling SetTopLevel(true) on the form does the trick. Any known
'side effects' of doing this?
 
J

Jay B. Harlow [MVP - Outlook]

Marina,
How do you show your dialog? Are you including the owner parameter?

Something like:

Private Sub menuHelpAbout_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles menuHelpAbout.Click
Dim dialog As New AboutDialog
Try
dialog.ShowDialog(Me)
Finally
dialog.Dispose()
End Try
End Sub

You shouldn't need to use SetTopLevel.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Hi,
|
| I'm opening a dialog in my application. If then I switch to another
| application (or if the dialog popped up while I was using another
| application), the dialog is often behind the main form, but I can't get to
| it. I can't do anything with the main form (because the dialog is open),
| but I can't bring focus back to the dialog. I have to use Alt +Tab, to be
| able to select it, which then gives the dialog focus again, so I can close
| it.
|
| But if I didn't do that, it just seems like the application is not
| responsive. If I was in another application when the dialog popped up, you
| can't even tell there was a dialog, so it just looks like the app froze.
| When in reality doing the Alt+Tab, allows you to select the dialog.
|
| Is there any way to make sure the dialog is always going to be on top of
the
| main form? It's being show using ShowDialog.
|
|
 
M

Marina

I didn't realize there was an overload like that. That makes sense, all set
now.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top