That could certainly be the problem Setting the TopMost property to true
will certainly place the Form on the top of the z-order of all windows on
the desktop, even if it is not the active or foreground form. If you want to
set it to TopMost, you could do it after the modal dialog returns. As to why
it steals the focus when you set it to false, I can't say. But perhaps you
should call the Activate method instead of setting the TopMost property. The
Activate method will bring the Form to the front of the z-order if it is the
Active Window, but only flash the window caption in the Task Bar if it is
not the Active Form. This can be overruled, but you might want to be sure
you want to do it. I believe you would have to use a WinAPI function to do
this, either SetForegroundWindow or SetActiveWindow (I believe it would be
SetForegroundWindow). See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setforegroundwindow.asp
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
I recycle.
I send everything back to the planet it came from.
[quoted text, click to view] "PIEBALD" <PIEBALD@discussions.microsoft.com> wrote in message
news:7D53F13E-CD49-4C18-83FA-0E7C02CFB491@microsoft.com...
> OK, I've got it behaving as expected now. It was, of course, my fault.
> But it raises another question.
>
> The problem was that I was setting the main form's TopMost property. The
> goal was to have the form "pop up" to the top when new data was displayed
> (but not otherwise).
>
> The rhetorical question now is: why does the form steal the focus and/or
> "pop up" when I set its TopMost property to false? I expect that to happen
> when I set it to true, but why does false seem to have the same effect?
>