-
June 24th, 2015, 05:04 AM
#1
Change resolution with ChangeDisplaySettings while desktop is extended causes black s
Hi.
I use this function to change resolution:
ChangeResolution(NULL,1440, 900);
bool ChangeResolution(WCHAR *sDeviceName, int iNewW, int iNewH)
{
DEVMODE oDEVMODE = { 0 };
oDEVMODE.dmSize = sizeof(DEVMODE);
EnumDisplaySettings(sDeviceName, ENUM_CURRENT_SETTINGS, &oDEVMODE);
oDEVMODE.dmPelsWidth = iNewW;
oDEVMODE.dmPelsHeight = iNewH;
bool bUpdateReg = true;
LONG lRet = ChangeDisplaySettings(&oDEVMODE, CDS_TEST | CDS_UPDATEREGISTRY);
if (lRet != DISP_CHANGE_SUCCESSFUL)
{
lRet = ChangeDisplaySettings(&oDEVMODE, CDS_TEST);
bUpdateReg = false;
}
if (lRet == DISP_CHANGE_SUCCESSFUL)
lRet = ChangeDisplaySettings(&oDEVMODE, bUpdateReg?CDS_UPDATEREGISTRY : 0);
return lRet == DISP_CHANGE_SUCCESSFUL;
}
This works well.
Problem happens when I desktop is extended (pressing the Windows key + P and choosing "extend"). Then while desktop is extended (to non psychical display), after using my ChangeResolution the screen become black as soon as my function calls ChangeDisplaySettings(&oDEVMODE, bUpdateReg?CDS_UPDATEREGISTRY : 0);
The way to get the screen back is to press Windows Key+P again and then press Enter.
(Since screen is black you do not really see what you do).
It becomes black no matter which new resolution i set.
If I try to change resolution while in extended mode but from Control Panel that is works great so the problem is with my function.
I think this happens since when i change resolution for the default screen (NULL), i also need to change something for the virtual screen - but i am not sure.
If that helps, seems that the screen goes black since for some reason after calling the changeresolution function, display1 is removed and display2 (the virtual screen) is on, but since there is not really physical display2 then i see black screen.
Question is why Display1 is removed when changing resolution?
Any help?
Thanks!
-
June 24th, 2015, 07:01 AM
#2
Re: Change resolution with ChangeDisplaySettings while desktop is extended causes bla
Victor Nijegorodov
-
June 24th, 2015, 07:45 AM
#3
Re: Change resolution with ChangeDisplaySettings while desktop is extended causes bla
Already tried ChangeDisplaySettingsEx with \\\\.\\DISPLAY1
Same results.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|