Marc Reinig
2004-08-27 21:33:44 UTC
I am trying to draw on a monitor that is not part of my desktop. It needs
to be an independent graphics display. For that, I think I need the HDC if
the monitor. If not, please let me know how to do it.
Here is what I have tried.
I can enumerate the display devices using
DISPLAY_DEVICE dd;
DISPLAY_DEVICE ddMon;
DWORD device = 0;
POINT pt;
while (EnumDisplayDevice(0, device, &dd, 0) )
{// Get each display device in turn
// Ignore Mirror drivers
if (!(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
{ // Get each monitor attached to the display device in turn
while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0))
{ // Only worry about the active monitor
if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE)
break;
devMon++;
}
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
{ //These monitors are part of the desktop
pt = dm.dmPosition.x, dm.dmPosition.y };
hm = MonitorFromPoint (pt,MONITOR_DEVAULTTONULL);
} // I can use MonitorFromXXX as above to get an hdc to draw on
// any part of the desktop
else
{ // how do I get the hm or hdc of the Monitors that are not
// part of the desktop?
// I tried the following four combinations but hdc comes back
// NULL.
hdc = CreateDC(ddMon.DeviceName, NULL, NULL, NULL );
hdc = CreateDC(ddMon.DeviceName, NULL, NULL, &dm );
hdc = CreateDC(dd.DeviceName, NULL, NULL, NULL );
hdc = CreateDC(dd.DeviceName, NULL, NULL, &dm );
When I try GetLastError, the translation is usually "Invalid Printer Name".
What am I doing wrong?
Thanks in advance,
Marc Reinig
UCO Lick, LAO
to be an independent graphics display. For that, I think I need the HDC if
the monitor. If not, please let me know how to do it.
Here is what I have tried.
I can enumerate the display devices using
DISPLAY_DEVICE dd;
DISPLAY_DEVICE ddMon;
DWORD device = 0;
POINT pt;
while (EnumDisplayDevice(0, device, &dd, 0) )
{// Get each display device in turn
// Ignore Mirror drivers
if (!(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
{ // Get each monitor attached to the display device in turn
while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0))
{ // Only worry about the active monitor
if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE)
break;
devMon++;
}
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
{ //These monitors are part of the desktop
pt = dm.dmPosition.x, dm.dmPosition.y };
hm = MonitorFromPoint (pt,MONITOR_DEVAULTTONULL);
} // I can use MonitorFromXXX as above to get an hdc to draw on
// any part of the desktop
else
{ // how do I get the hm or hdc of the Monitors that are not
// part of the desktop?
// I tried the following four combinations but hdc comes back
// NULL.
hdc = CreateDC(ddMon.DeviceName, NULL, NULL, NULL );
hdc = CreateDC(ddMon.DeviceName, NULL, NULL, &dm );
hdc = CreateDC(dd.DeviceName, NULL, NULL, NULL );
hdc = CreateDC(dd.DeviceName, NULL, NULL, &dm );
When I try GetLastError, the translation is usually "Invalid Printer Name".
What am I doing wrong?
Thanks in advance,
Marc Reinig
UCO Lick, LAO