Following Visual c++ 2008 Express' help on multiple monitors, I've managed to get a list of monitor devices via EnumDisplayDevices(..) [first enumerating adapters, then monitors in an inner loop]. Now I want to paint to one of the monitors; the help says I should just use
"hdc = CreateDC(lpszDisplayName, NULL, NULL, lpDevMode);
In this call, the lpszDisplayName parameter is one of the device names returned by EnumDisplayDevices and lpDevMode is a description of the graphics mode for this device. "
When I try this (with DISPLAY_DEVICE.DeviceName from EnumDisplayDevices, e.g. "\\.\DISPLAY1\Monitor0", as lpszDisplayName, and NULL as lpDevMode), I get the error code ERROR_INVALID_PRINTER_NAME (1801).
How can I fix this?
And could anyone help me towards preparing a minimalistic DevMode for just any graphics mode (ok, maybe of a given resolution)?
Why not simply take the desktop HDC (GetDC(0)) and figure out the monitor's area in the virtual desktop to paint on that monitor?
Well, it would be much preferable not to allow the mouse or any windows, dialogs, etc. to wander into that region, so I would prefer having the monitor not attached (e.g. part of) the desktop.
I presume desktop and virtual desktop are identical in this sense?
I've meanwhile discovered
It suggests that, whilst once possible, unattached screens cannot be painted on with modern versions of windows (or rather they can, but without producing actual output). It also claims that, as of 2004, the part of the visual studio help that I cited in the first post from my "2008 Express" version is outdated.
And the CreateDC approach I outlined before now works (without producing output on unattached screens, but also without any failing GDI drawing calls), with the code listed in the above link, although that seems to depend on compiling for unicode. This I've learned from (and partially verified)
Guess I'll resign into using a desktop extended over both monitors. Pity.
Yeah, the way Windows manages multiple monitors is to have them occupy different rectangles of a virtual desktop. I don't think you can have a monitor that can be drawn to independently but isn't part of the virtual desktop.
Plus, it seems to me you shouldn't really be drawing to the monitor's DC anyway, but rather create a window that covers the entire monitor and draw to that. If you draw directly to the monitor's DC, your drawing and Windows' own drawing of the wallpaper and so forth might fight with each other.
It suggests that, whilst once possible, unattached screens cannot be painted on with modern versions of windows (or rather they can, but without producing actual output).
That's true, if I disable the desktop on my other monitor it goes into standby, and changing the resolution in the config panel has no effect. But I wonder, what happens if you change the resolution using ChangeDisplaySettingsEx() for that display?
Thanks for the help.
Obviously the window creation method is the better one;
the only reason I was interested in creating a DC for an entire monitor was that my Visual C++ 2008 Express Edition mislead me into thinking that this way I could use a monitor for output where windows intenionally cannot be created. Which apparently is a feature discontinued around the turn of the millenium.