void
vncDesktop::Checkmonitors()
{
nr_monitors=GetNrMonitors();
DEVMODE devMode;
if (nr_monitors>0)
{
if(OSVersion()!=3 && OSVersion()!=5)GetPrimaryDevice();
devMode.dmSize = sizeof(DEVMODE);
if(OSVersion()!=3 && OSVersion()!=5) EnumDisplaySettings(mymonitor[0].device, ENUM_CURRENT_SETTINGS, &devMode);
else EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);
mymonitor[0].offsetx=devMode.dmPosition.x;
mymonitor[0].offsety=devMode.dmPosition.y;
mymonitor[0].Width=devMode.dmPelsWidth;
mymonitor[0].Height=devMode.dmPelsHeight;
mymonitor[0].Depth=devMode.dmBitsPerPel;
}
if (nr_monitors>1)
{
GetSecondaryDevice();
devMode.dmSize = sizeof(DEVMODE);
EnumDisplaySettings(mymonitor[1].device, ENUM_CURRENT_SETTINGS, &devMode);
mymonitor[1].offsetx=devMode.dmPosition.x;
mymonitor[1].offsety=devMode.dmPosition.y;
mymonitor[1].Width=devMode.dmPelsWidth;
mymonitor[1].Height=devMode.dmPelsHeight;
mymonitor[1].Depth=devMode.dmBitsPerPel;
}
mymonitor[2].offsetx=GetSystemMetrics(SM_XVIRTUALSCREEN);
mymonitor[2].offsety=GetSystemMetrics(SM_YVIRTUALSCREEN);
mymonitor[2].Width=GetSystemMetrics(SM_CXVIRTUALSCREEN);
mymonitor[2].Height=GetSystemMetrics(SM_CYVIRTUALSCREEN);
mymonitor[2].Depth=mymonitor[0].Depth;//depth primary monitor is used
}
Checkmonitors();
asked_display=m_buffer.GetDisplay();
current_monitor=1;
if (asked_display==2 && nr_monitors>1) current_monitor=2;
if (asked_display==3 && nr_monitors>1) current_monitor=3;
if (current_monitor==3) current_monitor=1;
if (current_monitor==1)
{
m_hrootdc = CreateDC(("DISPLAY"
,mymonitor[0].device,NULL,NULL);
m_ScreenOffsetx=mymonitor[0].offsetx;
m_ScreenOffsety=mymonitor[0].offsety;
}
if (current_monitor==2)
{
m_hrootdc =CreateDC(("DISPLAY"
,mymonitor[1].device,NULL,NULL);
m_ScreenOffsetx=mymonitor[1].offsetx;
m_ScreenOffsety=mymonitor[1].offsety;
}
if (current_monitor==3)
{
m_hrootdc = GetDC(NULL);
m_ScreenOffsetx=mymonitor[2].offsetx;
m_ScreenOffsety=mymonitor[2].offsety;;
}
if (m_hrootdc == NULL) {
vnclog.Print(LL_INTERR, VNCLOG("Failed m_rootdc /n"
);
return FALSE;
}