On my Win7 PC I have the start-bar running vertically, it’s about 60px wide. In my win32 application, the created window always appears overlapping the start bar, which looks bad – I just use (0,0) as the top-left position for the window.
How should I be doing it to get (0,0) relative to the desktop, taking the Start Bar into account? Is there a flag, or do I manually need to look up a metric?
There are a few problems here. You don’t want to use a hard-coded value like (0,0). That might not even be visible on a multi-monitor system. As you have discovered, you should try to avoid overlapping with the taskbar or other appbars. If there are multiple monitors you should try and start on the monitor where the user has most recently interacted.
There is a simple way to make much of this happen for free. Pass
CW_USEDEFAULTas thexandycoordinates when you callCreateWindow. This will let the window manager do the hard work of making your window appear in a sensible location.You can get the system to tell you the coordinates of the work area. The work area is that part of the desktop that does not contain the taskbar or other appbars. Call
SystemParametersInfopassingSPI_GETWORKAREA.