Holy cow, I wrote a book!
how Windows chooses where to place a newly-opened window
on a multiple-monitor system
and gives as an example an application whose monitor choice
The easy part is if the application specifies where it wants the
window to be.
In that case, the window is placed at the requested location.
How the application chooses those coordinates is up to the application.
On the other hand, if the application passes
this means that the application is saying,
"I have no opinion where the window should go.
Please pick a place for me."
If this is the first top-level window created by the application with
CW_USEDEFAULT as its position,
and the STARTF_USEPOSITION flag is set in the
then use the position provided in the
dwX and dwY members.
Officially, that's all you're going to see in the documentation.
Past this point is all implementation detail.
I'm providing it here to satisfy your curiosity,
but please don't write code that relies on it.
(This is, I realize, a meaningless request, but I must go through
the motions of making it anyway.)
Okay, now let's dive into the various levels of automatic window
positioning the window manager performs.
Remember, these algorithms are not contractual and can change
at any time.
(In fact, they have changed in the past.)
Just to make it harder to rely on this algorithm,
I will not tell you which operating system implements
the algorithm described below.
From now on, assume that the application has specified
CW_USEDEFAULT as its position.
Also assume that the window is a top-level window.
First we have to choose a monitor.
Next, we have to choose a location on that monitor.
The effect of this algorithm is that if you open a bunch of
default-positioned windows on a monitor, they line up in a pretty
cascade marching down and to the right,
until the cascade goes too far, and then they return to the upper
left and resume cascading.
Finally, after choosing a monitor and a location on the monitor,
the selected location is adjusted (if possible)
so that the window does not span monitors.
And that's it, the default-window-positioning algorithm,
as it existed in an unspecified version of Windows.
Remember, this algorithm has been tweaked in the past,
it will get tweaked more in the future,
so don't rely on it.