views:

996

answers:

2

Thinking about this for an About dialog but I'm sure it's applicable in other places (say a find box)

Sorry if this is a dupe, but I couldn't find this or how to articulate the last part about it only being on top of the parent. How do you make a form that is always on top of the parent form, but is non-modal, but doesn't cover up other apps?

+3  A: 

Try this to open your dialog:

FindDialog fd = new FindDialog();
fd.Show(this);

The key is to assign dialog's owner.

Jay Riggs
Knew it had to be something simple, thanks!
Davy8
A: 

Not sure exactly what you mean; Form.ShowDialog is only modal with respect to the parent, not the application, unless the application is single threaded.

For example, I made an app to test this which was organized like the following:

mainform: 2 buttons, each of which begins a thread that creates a frmDialog1 and calls ShowDialog

frmDialog1: single button which creates a frmDialog2 and calls ShowDialog on it.

frmDialog2: does nothing (ie. blank)

when they were all running I could access/drag mainform. I could also do the same with frmDialog1 (both versions) only if I hadn't clicked the button that shows dialog 2.

SnOrfus
"Form.ShowDialog is only modal with respect to the parent, not the application, unless the application is single threaded." Right, but I want it non-modal with respect to the parent, however I still wanted it always on top of the parent.
Davy8
Also, you're right that I could start a new thread to display the dialog to not block the main UI, but I try to avoid manual threading if I can help it. I don't need the dialog result, it's just an About dialog after all, so starting a thread seems overkill.
Davy8
As it's your app I'll defer to your wisdom; but a 2 liner Thread whatever = new Thread(methodname); whatever.Start(); is hardly overkill.
SnOrfus