2

I've been working on using P/Invoke (post to follow) for multi-monitor support with Silverlight 5. Whilst playing, I noticed that window size and position would determine which of my two monitors an additional Window was maximised onto. I continued playing (as you do) and determined that:

  • with my laptop (1280 x 800) on the left as primary and monitor (1024 x 768) on the right, the formula was Left = -(Width/2) + 1271
  • with my monitor (1024 x 768) on the left as primary and laptop (1280 x 800) on the right, the formula was Left = -(Width/2) + 1014
  • with my monitor (1024 x 768) on the left and laptop (1280 x 800) on the right as primary, the formula was Left = -(Width/2) - 11
  • with my laptop (1280 x 800) on the left and monitor (1024 x 768) on the right as primary, the formula was Left = -(Width/2) - 10

It looks like there should be a pattern (constant = screen width - 10 for primary on the left, constant = -10 for primary on the right) but it's not exact. I don't have other monitors available at the moment, to check. Anyone know what it should be, or if this is just an artefact of my particular set up?

(Note: there are limits to these - they don't work for all value of Left or Width)

SGarratt
  • 984
  • 1
  • 8
  • 22

1 Answers1

2

This behavior seems to be consistent with the behavior of MonitorFromWindow. From the documentation:

The MonitorFromWindow function retrieves a handle to the display monitor that has the largest area of intersection with the bounding rectangle of a specified window.

Check to see if this is consistent with your calculations. It should be.

MrGomez
  • 23,788
  • 45
  • 72
  • It's close but not quite that, unless the description is missing some details. If that was the case, then the values of Left and Width that shove the window onto the second monitor (on the RHS) should give (Width/2) + Left = (first pixel of RHS monitor) e.g. the left (primary) monitor is 1280 wide, Width = 400, Left = 1080 because pixels are numbered 0-1279, so 1280 is the first) but they actually give the value of ((first pixel of RHS monitor) - 10) or 1270 in the above case. And similarly (but not exactly 10) for other primary/secondary monitor positions. – SGarratt Apr 01 '12 at 18:08