Reputation: 1397
I have a borderless form displayed as a progress object. This is displayed via childform.show().
I'm overriding CS_DROPSHADOW to give it the shadow (pictured), when the form loses focus (parent clicked or another form\application) the shadow is lost.
How can I keep the form focused\selected similar to a modal form? (I cannot use showdialog due this being called from various threads other than UI) Using Me.TopMost = True works, but obviously puts the form above all others rather than just the parent.
Upvotes: 0
Views: 1244
Reputation: 941505
As long as you are creating this window in a worker thread then you really are stuck with TopMost = true. Winforms won't let you use the Show(owner) overload, it throws an InvalidOperationException when it detects that the parent is owned by the UI thread. Just calling Show() makes the desktop window the owner. Which is a problem, the progress window can disappear behind another window and the user can't easily get it back. Since it is asynchronous, this can easily happen while the user is working in a UI window, she might never even notice the popup.
Just punt this problem, use Control.BeginInvoke() to let a method create the dialog on the UI thread. Now you can call ShowDialog(), all your problems are solved.
Upvotes: 1