Changeset 19836 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
- Timestamp:
- May 19, 2009 6:44:04 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r19705 r19836 233 233 paDisplayDevices[DevNum] = DisplayDevice; 234 234 235 /* First try to get the video mode stored in registry (ENUM_REGISTRY_SETTINGS). 236 * A secondary display could be not active at the moment and would not have 237 * a current video mode (ENUM_CURRENT_SETTINGS). 238 */ 235 239 ZeroMemory(&paDeviceModes[DevNum], sizeof(DEVMODE)); 236 240 paDeviceModes[DevNum].dmSize = sizeof(DEVMODE); … … 242 246 } 243 247 244 Log(("ResizeDisplayDevice: %dx%d at %d,%d\n", 248 if ( paDeviceModes[DevNum].dmPelsWidth == 0 249 || paDeviceModes[DevNum].dmPelsHeight == 0) 250 { 251 /* No ENUM_REGISTRY_SETTINGS yet. Seen on Vista after installation. 252 * Get the current video mode then. 253 */ 254 ZeroMemory(&paDeviceModes[DevNum], sizeof(DEVMODE)); 255 paDeviceModes[DevNum].dmSize = sizeof(DEVMODE); 256 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName, 257 ENUM_CURRENT_SETTINGS, &paDeviceModes[DevNum])) 258 { 259 Log(("EnumDisplaySettings(ENUM_CURRENT_SETTINGS) err %d\n", GetLastError ())); 260 return FALSE; 261 } 262 } 263 264 Log(("ResizeDisplayDevice: %dx%dx%d at %d,%d\n", 245 265 paDeviceModes[DevNum].dmPelsWidth, 246 266 paDeviceModes[DevNum].dmPelsHeight, 267 paDeviceModes[DevNum].dmBitsPerPel, 247 268 paDeviceModes[DevNum].dmPosition.x, 248 269 paDeviceModes[DevNum].dmPosition.y)); … … 303 324 tempDevMode.dmSize = sizeof(DEVMODE); 304 325 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode); 305 BOOL bUpdateMonitor = FALSE;306 LONG status = 0;307 326 308 327 /* Assign the new rectangles to displays. */ … … 314 333 paDeviceModes[i].dmPelsHeight = paRects[i].bottom - paRects[i].top; 315 334 316 paDeviceModes[i].dmFields = DM_POSITION | DM_PELSHEIGHT | DM_PELSWIDTH; 335 /* On Vista one must specify DM_BITSPERPEL. 336 * Note that the current mode dmBitsPerPel is already in the DEVMODE structure. 337 */ 338 paDeviceModes[i].dmFields = DM_POSITION | DM_PELSHEIGHT | DM_PELSWIDTH | DM_BITSPERPEL; 317 339 318 340 if ( i == Id 319 341 && BitsPerPixel != 0) 320 342 { 321 paDeviceModes[i].dmFields |= DM_BITSPERPEL;343 /* Change dmBitsPerPel if requested. */ 322 344 paDeviceModes[i].dmBitsPerPel = BitsPerPixel; 323 345 } 324 346 325 /* Test if the mode can be set. */ 326 Log(("ResizeDisplayDevice: Testing if the mode can be set ...\n")); 327 SetLastError(0); 328 status = gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 329 &paDeviceModes[i], NULL, CDS_TEST, NULL); 330 if (status == DISP_CHANGE_SUCCESSFUL) 331 { 332 Log(("ResizeDisplayDevice: Mode can be set! Calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx)); 333 gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 334 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 335 Log(("ResizeDisplayDevice: ChangeDisplaySettingsEx position err %d\n", GetLastError ())); 336 bUpdateMonitor = TRUE; 337 } 338 else 339 { 340 if (status == DISP_CHANGE_BADMODE) 341 { 342 Log(("ResizeDisplayDevice: Unsupported mode specified. No changes made.\n")); 343 } 344 else Log(("ResizeDisplayDevice: Mode can NOT be set! Error: %d\n", status)); 345 } 347 Log(("ResizeDisplayDevice: pfnChangeDisplaySettingsEx %x: %dx%dx%d at %d,%d\n", 348 gCtx.pfnChangeDisplaySettingsEx, 349 paDeviceModes[i].dmPelsWidth, 350 paDeviceModes[i].dmPelsHeight, 351 paDeviceModes[i].dmBitsPerPel, 352 paDeviceModes[i].dmPosition.x, 353 paDeviceModes[i].dmPosition.y)); 354 355 gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 356 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 357 Log(("ResizeDisplayDevice: ChangeDisplaySettingsEx position err %d\n", GetLastError ())); 346 358 } 347 359 348 360 /* A second call to ChangeDisplaySettings updates the monitor. */ 349 if (bUpdateMonitor) 350 { 351 status = ChangeDisplaySettings(NULL, 0); 352 Log(("ResizeDisplayDevice: ChangeDisplaySettings update status %d\n", status)); 353 if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE) 354 { 355 /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */ 356 return FALSE; 357 } 358 359 /* Retry the request. */ 360 return TRUE; 361 } 362 363 return FALSE; /* Don't retry; maybe something went wrong. */ 361 LONG status = ChangeDisplaySettings(NULL, 0); 362 Log(("ResizeDisplayDevice: ChangeDisplaySettings update status %d\n", status)); 363 if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE) 364 { 365 /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */ 366 return FALSE; 367 } 368 369 /* Retry the request. */ 370 return TRUE; 364 371 } 365 372
Note:
See TracChangeset
for help on using the changeset viewer.