Created
January 3, 2014 15:20
-
-
Save lennartb-/8239571 to your computer and use it in GitHub Desktop.
Switches the active display to the inactive and vice verse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SwitchActiveInactive() { | |
GetDisplayInfo(); | |
// Negative x numbers = left | |
ddInactive.dmPosition.x = -1920; | |
ddInactive.dmPosition.y = 0; | |
ddInactive.dmFields = DM.Position; | |
var res = ChangeDisplaySettingsEx( | |
szInactiveDeviceName, | |
ref ddInactive, | |
IntPtr.Zero, | |
(int)(CDSFlags.CDS_NORESET | CDSFlags.CDS_UPDATEREGISTRY| CDSFlags.CDS_SET_PRIMARY ), IntPtr.Zero); | |
ddActive.dmPosition.x = 0; | |
ddActive.dmPosition.y = 0; | |
ddActive.dmPelsHeight = 0; | |
ddActive.dmPelsWidth = 0; | |
ddActive.dmFields = DM.Position | DM.PelsHeight | DM.PelsWidth; | |
ChangeDisplaySettingsEx(szActiveDeviceName, ref ddActive, IntPtr.Zero, (int)CDSFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); | |
Console.WriteLine(res.ToString()); | |
ChangeDisplaySettings(IntPtr.Zero, IntPtr.Zero); | |
Console.ReadKey(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment