Setting Primary Display
-
Hi, I'm trying to set the Primary Display...without success! Here's the code I'm working on, would you please help me see what I'm doing wrong there? There's no compilation error...it simply doesn't give the expected result! Thank you!!
Imports System.Runtime.InteropServices
Class MainWindow
Const CCDEVICENAME As Short = 32
Const CCFORMNAME As Short = 32Private Const MONITORINFOF\_PRIMARY As Integer = &H1 Private Const DISPLAY\_DEVICE\_ATTACHED\_TO\_DESKTOP As Integer = &H1 Private Const DISPLAY\_DEVICE\_PRIMARY\_DEVICE As Integer = &H4 Private Const DISPLAY\_DEVICE\_MIRRORING\_DRIVER As Integer = &H8 Private Const DISPLAY\_DEVICE\_VGA\_COMPATIBLE As Integer = &H10 Private Const DISPLAY\_DEVICE\_REMOVABLE As Integer = &H20 Private Const DISPLAY\_DEVICE\_MODESPRUNED As Integer = &H8000000 Private Const DM\_POSITION = &H20 Private Const DM\_DISPLAYORIENTATION = &H80 ' XP only Private Const DM\_BITSPERPEL = &H40000 Private Const DM\_PELSWIDTH = &H80000 Private Const DM\_PELSHEIGHT = &H100000 Private Const DM\_DISPLAYFLAGS = &H200000 Private Const DM\_DISPLAYFREQUENCY = &H400000 'Private Const DM\_DISPLAYFIXEDOUTPUT As Long = &H20000000 ' XP only Private Const ENUM\_CURRENT\_SETTINGS As Integer = -1 Private Const ENUM\_REGISTRY\_SETTINGS As Integer = -2 Private Const EDS\_RAWMODE As Integer = &H2 Private Const CDS\_UPDATEREGISTRY As Integer = &H1 Private Const CDS\_TEST As Integer = &H2 Private Const CDS\_FULLSCREEN As Integer = &H4 Private Const CDS\_GLOBAL As Integer = &H8 Private Const CDS\_SET\_PRIMARY As Integer = &H10 Private Const CDS\_VIDEOPARAMETERS As Integer = &H20 Private Const CDS\_NORESET As Integer = &H10000000 Private Const CDS\_RESET As Integer = &H40000000 Private Const CDS\_FORCE As Integer = &H80000000 Private Const CDS\_NONE As Integer = 0 Public Structure PointL Dim x As Integer Dim y As Integer End Structure \_ Enum DisplayDeviceStateFlags As Integer AttachedToDesktop = &H1 MultiDriver = &H2 PrimaryDevice = &H4 MirroringDriver = &H8 VGACompatible = &H10 Removable = &H20 ModesPruned = &H8000000 Remote = &H4000000 Disconnect = &H2000000 End Enum '0 is Not Attached Const DISPLAY\_PRIMARY\_DEVICE = &H4 'Primary device 'Holds the information of display adpter Private Structure DISPLAY\_DEVICE
-
Hi, I'm trying to set the Primary Display...without success! Here's the code I'm working on, would you please help me see what I'm doing wrong there? There's no compilation error...it simply doesn't give the expected result! Thank you!!
Imports System.Runtime.InteropServices
Class MainWindow
Const CCDEVICENAME As Short = 32
Const CCFORMNAME As Short = 32Private Const MONITORINFOF\_PRIMARY As Integer = &H1 Private Const DISPLAY\_DEVICE\_ATTACHED\_TO\_DESKTOP As Integer = &H1 Private Const DISPLAY\_DEVICE\_PRIMARY\_DEVICE As Integer = &H4 Private Const DISPLAY\_DEVICE\_MIRRORING\_DRIVER As Integer = &H8 Private Const DISPLAY\_DEVICE\_VGA\_COMPATIBLE As Integer = &H10 Private Const DISPLAY\_DEVICE\_REMOVABLE As Integer = &H20 Private Const DISPLAY\_DEVICE\_MODESPRUNED As Integer = &H8000000 Private Const DM\_POSITION = &H20 Private Const DM\_DISPLAYORIENTATION = &H80 ' XP only Private Const DM\_BITSPERPEL = &H40000 Private Const DM\_PELSWIDTH = &H80000 Private Const DM\_PELSHEIGHT = &H100000 Private Const DM\_DISPLAYFLAGS = &H200000 Private Const DM\_DISPLAYFREQUENCY = &H400000 'Private Const DM\_DISPLAYFIXEDOUTPUT As Long = &H20000000 ' XP only Private Const ENUM\_CURRENT\_SETTINGS As Integer = -1 Private Const ENUM\_REGISTRY\_SETTINGS As Integer = -2 Private Const EDS\_RAWMODE As Integer = &H2 Private Const CDS\_UPDATEREGISTRY As Integer = &H1 Private Const CDS\_TEST As Integer = &H2 Private Const CDS\_FULLSCREEN As Integer = &H4 Private Const CDS\_GLOBAL As Integer = &H8 Private Const CDS\_SET\_PRIMARY As Integer = &H10 Private Const CDS\_VIDEOPARAMETERS As Integer = &H20 Private Const CDS\_NORESET As Integer = &H10000000 Private Const CDS\_RESET As Integer = &H40000000 Private Const CDS\_FORCE As Integer = &H80000000 Private Const CDS\_NONE As Integer = 0 Public Structure PointL Dim x As Integer Dim y As Integer End Structure \_ Enum DisplayDeviceStateFlags As Integer AttachedToDesktop = &H1 MultiDriver = &H2 PrimaryDevice = &H4 MirroringDriver = &H8 VGACompatible = &H10 Removable = &H20 ModesPruned = &H8000000 Remote = &H4000000 Disconnect = &H2000000 End Enum '0 is Not Attached Const DISPLAY\_PRIMARY\_DEVICE = &H4 'Primary device 'Holds the information of display adpter Private Structure DISPLAY\_DEVICE
Well did you step through it in the debugger and check the return values from the functions that do the work? You need to narrow it down to exactly which function call is not working as intended.
The difficult we do right away... ...the impossible takes slightly longer.
-
Well did you step through it in the debugger and check the return values from the functions that do the work? You need to narrow it down to exactly which function call is not working as intended.
The difficult we do right away... ...the impossible takes slightly longer.
-
Did you study the documentation? ChangeDisplaySettingsEx function (Windows)[^]
The difficult we do right away... ...the impossible takes slightly longer.