Post Reply

Forums -> Multiple monitors -> Extends Desktop onto this Monitor Programmatically
Muhammad Afzaal   2006-02-03 05:40
Hi Christian Studer
I am writing program to "Extends Desktop onto second Monitor" programmatically without using Display properties window. My secondary monitor is "MOBILITY RADEON 9200". I am using ChangeDisplaySettingEx function. In this function i passed three significant arguments
1. Device Name,
2. DEVMODE with dmFields=DM_POSITION and also dmPosition.x =800 dmPosition.y =600

3. dmFlags to CDS_RESET. But when i run this program it always give me an error :

The display driver failed the specified graphics mode

I am attaching program which is written in VB6. Please if you can help me out.

regards
AFZAAL
Muhammad Afzaal   2006-02-03 21:52
Hers is the code snapshot

Do While EnumDisplayDevices(vbNullString, dev, dd, 0) <> 0
If Not CBool(dd.StateFlags And DISPLAY_DEVICE_MIRRORING_DRIVER) Then
If Not CBool(dd.StateFlags And DISPLAY_DEVICE_PRIMARY_DEVICE) Then

'get information about the display's position and the current display mode

If EnumDisplaySettingsEx(dd.deviceName, ENUM_CURRENT_SETTINGS, dm, 0) = 0 Then
EnumDisplaySettingsEx dd.deviceName, ENUM_REGISTRY_SETTINGS, dm, 0
End If

If Not CBool(dd.StateFlags And DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) Then
'attach to the desktop
dm.dmFields = DM_POSITION Or DM_BITSPERPEL
dm.dmBitsPerPel = bpp
dm.dmPosition.x = cx
dm.dmPosition.y = 0
su = ChangeDisplaySettingsEx(dd.deviceName, dm, 0, CDS_TEST, vbNull)
If su = 0 Then
su = ChangeDisplaySettingsEx(dd.deviceName, dm, 0, CDS_UPDATEREGISTRY Or CDS_NORESET Or CDS_GLOBAL, vbNull)
If su <> 0 Then
printError su
Else
EnumDisplaySettingsEx dd.deviceName, ENUM_REGISTRY_SETTINGS, ds, 0
su = ChangeDisplaySettingsEx(dd.deviceName, ds, 0, CDS_RESET, 0)
If su <> 0 Then
printError su
End If
End If
End If
End If
End If
End If

regards
AFZAAL
Forums -> Multiple monitors -> Extends Desktop onto this Monitor Programmatically

Post Reply