views:

196

answers:

2

I've determined that I can use GetSystemMetrics(SM_CMONITORS) to query the number of attached monitors, but is their any way to control what monitor CreateWindowEx() uses for the window?

+3  A: 

Yes, by the "x" and "y" arguments. Use EnumDisplayMonitors (pass two nulls) to enumerate the monitors. Your MonitorEnumProc callback gets a RECT* to the monitor's display rectangle. You'd get a negative RECT.right if a monitor is located at the left of your main one.

Hans Passant
+2  A: 

Each monitor simply displays some part of the desktop, so showing the window on a particular monitor is a matter of moving the window to the part of the desktop displayed by that monitor. When you call CreateWindowEx (or CreateWindow) you can specify x and y coordinates for the window, so displaying it on a particular monitor simply means specifying coordinates that fall within the area displayed by that monitor.

You can find the work areas for the monitors on a system with GetMonitorInfo.

Jerry Coffin