views:

251

answers:

2

I dock the taskbar to the left, which causes many windows to open underneath the taskbar.

None of the System.Windows.Form.FormStartPosition values take into account the taskbar except for Manual. Is this by design? It's frustrating. I want to respect the default monitor and window position values that the OS should enforce.

+1  A: 

I think there is no .NET way to do that. I don't see any reasons to have such one.

You can locate taskbar position and put your form there manually.

abatishchev
The reason I gave isn't sufficient? A windows' default starting position should respect the tasbkar if "Keep taskbar on top of other windows" is checked. See OS X.The alternative is to find what the above preference is set to, find the monitor on which windows are supposed to open by default, discover if the taskbar is attached to the window, and if so manually compute the starting position.
Cat
+5  A: 

Well, if WinForms doesn't do this automatically, you may have to set this manually.

You'd have to use System.Windows.Forms.Screen.PrimaryScreen.WorkingArea to get the area of the screen without the taskbar, and use that Rectangle to compute the startup area for the form manually, and set it as the Form's Bounds property. (Make sure the form is using FormStartPosition.Manual).

MiffTheFox
I also have to check if the taskbar is set to auto-hide and if the user wants the taskbar to appear over windows. Argh.
Cat
I generally find that if you want your program to be "nice" and not have all those little pet peeves then you actually have a lot of extra work on your hands. And it's a real shame that only very few users will appreciate that (but yourself being one such user is an important enough reason to do the work :D)
romkyns