As a courtesy to developers out there, I'd like to remind all who write and develop Windows applications to take the time to position your windows (forms) properly on the screen. Not all users have their taskbar on the bottom on the screen. I am constantly annoyed by applications that assume that 0,0 is the upper left corner of the screen and that it's a safe place to position your windows - especially because I like my task bar along the left side and toolbars across the top. This configuration is, to me, extremely productive especially with a widescreen monitor.
The list of applications that don't position themselves correctly is too long to mention, but some tools that I quite frequently use (almost daily) are ILDASM and Virtual PC. ILDASM has the annoying nuance in that it always starts in the upperleft corner of the screen (0,0) so the entire titlebar always appears (or rather doesn't appear) completely obscured beneath the taskbar/toolbars - thank goodness for the ALT key and system menus. Virtual PC never quite stays in the same place, creeping towards 0,0 each time you open it.
It's not hard to get it right. If your application requires manual placement of the form you simply need to call Screen.GetWorkingArea([form variable]) to get the screen on which (the majority of) your form is positioned. Then you can do a little magic otherwise known as basic math and you have it.
The following example identifies how to do this:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WorkingAreaTest {
public sealed class EntryPoint {
[STAThread()]
public static void Main() {
Form f = new Form();
f.StartPosition = FormStartPosition.Manual;
Rectangle rct = Screen.PrimaryScreen.WorkingArea;
// you could also call Screen.GetWorkingArea(f)
// to center the form on the screen
// by bitshifting to divide by 2, we get two benefits:
// 1) improved performance (negligible here)
// 2) we don't need to cast the result to an int
f.Location = new Point(
(rct.Left + (rct.Width >> 1) - (f.Width >> 1)),
(rct.Top + (rct.Height >> 1) - (f.Height >> 1)));
// to position the form on the upperleft corner of the screen
f.Location = new Point(rct.Left, rct.Top);
// show the form and get the application running
Application.Run(f);
}
}
}
If you're programming a traditional Windows applications (non-.NET), you can use the SystemParametersInfo() function passing in SPI_GETWORKAREA.
RECT rct;
BOOL ret = SystemParametersInfo(SPI_GETWORKAREA, 0, &rct, 0);
Well, there you go, not much too it at all...and your users will thank you for it, or maybe they'll use your program and never notice you did thim this courtesy - and that's the best praise one could receive. Believe me, they'll notice if you don't.