M
MikeZ
Can anyone tell me how to enable a secondary monitor in XPe? I have a
Composite Video out that I am attempting to connect to a TV. I can see
the secondary monitor in Display Properties, but when I try to "Extend
my desktop", the screen flashes but the secondary monitor isn't enabled.
If I go back into Display Properties, it is still unchecked.
I've tried using the following code to enable the secondary monitor with
no luck. Any thoughts or direction is appreciated. Thank you, Mike
BOOL bFoundSecondary = FALSE;
nWidth = this->GetDC()->GetDeviceCaps(HORZRES);
// Initialize DisplayDevice.
ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));
DisplayDevice.cb = sizeof(DisplayDevice);
LONG retCode;
// Get display devices.
while ((EnumDisplayDevices(NULL, DispNum, &DisplayDevice, 0)) &&
(bFoundSecondary == FALSE))
{
ZeroMemory(&defaultMode, sizeof(DEVMODE));
defaultMode.dmSize = sizeof(DEVMODE);
if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName,
ENUM_REGISTRY_SETTINGS, &defaultMode))
return FALSE; // Store default failed
CString errStr;
if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))
{
//Found the first secondary device.
bFoundSecondary = TRUE;
defaultMode.dmSize = sizeof(DEVMODE);
defaultMode.dmPosition.x = nWidth;
defaultMode.dmPosition.y = 0;
defaultMode.dmFields = DM_POSITION;
VIDEOPARAMETERS vp = {0};
vp.Guid = GUID_VIDEOPARAMETERS;
vp.dwCommand = VP_COMMAND_SET;
vp.dwFlags = VP_FLAGS_TV_MODE | VP_FLAGS_TV_STANDARD;
vp.dwMode = VP_MODE_TV_PLAYBACK;
vp.dwTVStandard = VP_TV_STANDARD_NTSC_M;
retCode = ChangeDisplaySettingsEx(
(LPSTR)DisplayDevice.DeviceName, &defaultMode, NULL,
CDS_VIDEOPARAMETERS|CDS_NORESET|CDS_UPDATEREGISTRY,
&vp);
if (retCode != DISP_CHANGE_SUCCESSFUL)
{
errStr.Format("POS: %ld", retCode);
MessageBox(errStr);
}
// A second call to ChangeDisplaySettings updates the monitor.
retCode = ChangeDisplaySettings(NULL, 0);
if (retCode != DISP_CHANGE_SUCCESSFUL)
{
errStr.Format("RESET: %ld", retCode);
MessageBox(errStr);
}
}
// Reinitialize DisplayDevice.
ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));
DisplayDevice.cb = sizeof(DisplayDevice);
DispNum++;
} // End while the display devices.
Composite Video out that I am attempting to connect to a TV. I can see
the secondary monitor in Display Properties, but when I try to "Extend
my desktop", the screen flashes but the secondary monitor isn't enabled.
If I go back into Display Properties, it is still unchecked.
I've tried using the following code to enable the secondary monitor with
no luck. Any thoughts or direction is appreciated. Thank you, Mike
BOOL bFoundSecondary = FALSE;
nWidth = this->GetDC()->GetDeviceCaps(HORZRES);
// Initialize DisplayDevice.
ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));
DisplayDevice.cb = sizeof(DisplayDevice);
LONG retCode;
// Get display devices.
while ((EnumDisplayDevices(NULL, DispNum, &DisplayDevice, 0)) &&
(bFoundSecondary == FALSE))
{
ZeroMemory(&defaultMode, sizeof(DEVMODE));
defaultMode.dmSize = sizeof(DEVMODE);
if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName,
ENUM_REGISTRY_SETTINGS, &defaultMode))
return FALSE; // Store default failed
CString errStr;
if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))
{
//Found the first secondary device.
bFoundSecondary = TRUE;
defaultMode.dmSize = sizeof(DEVMODE);
defaultMode.dmPosition.x = nWidth;
defaultMode.dmPosition.y = 0;
defaultMode.dmFields = DM_POSITION;
VIDEOPARAMETERS vp = {0};
vp.Guid = GUID_VIDEOPARAMETERS;
vp.dwCommand = VP_COMMAND_SET;
vp.dwFlags = VP_FLAGS_TV_MODE | VP_FLAGS_TV_STANDARD;
vp.dwMode = VP_MODE_TV_PLAYBACK;
vp.dwTVStandard = VP_TV_STANDARD_NTSC_M;
retCode = ChangeDisplaySettingsEx(
(LPSTR)DisplayDevice.DeviceName, &defaultMode, NULL,
CDS_VIDEOPARAMETERS|CDS_NORESET|CDS_UPDATEREGISTRY,
&vp);
if (retCode != DISP_CHANGE_SUCCESSFUL)
{
errStr.Format("POS: %ld", retCode);
MessageBox(errStr);
}
// A second call to ChangeDisplaySettings updates the monitor.
retCode = ChangeDisplaySettings(NULL, 0);
if (retCode != DISP_CHANGE_SUCCESSFUL)
{
errStr.Format("RESET: %ld", retCode);
MessageBox(errStr);
}
}
// Reinitialize DisplayDevice.
ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));
DisplayDevice.cb = sizeof(DisplayDevice);
DispNum++;
} // End while the display devices.