コード例 #1
0
 // helper for creating an initialized DEVMODE structure
 public static Devmode CreateDevmode()
 {
     var dm = new Devmode
     {
         dmDeviceName = new string(new char[32]),
         dmFormName = new string(new char[32])
     };
     dm.dmSize = (short) Marshal.SizeOf(dm);
     return dm;
 }
コード例 #2
0
        // helper for creating an initialized DEVMODE structure
        public static Devmode CreateDevmode()
        {
            var dm = new Devmode
            {
                dmDeviceName = new string(new char[32]),
                dmFormName   = new string(new char[32])
            };

            dm.dmSize = (short)Marshal.SizeOf(dm);
            return(dm);
        }
コード例 #3
0
        public void For(int rotation, uint deviceId)
        {
            //uint deviceId = 1; // zero origin (i.e. 1 means DISPLAY2)

            var displayDevice = new DisplayDevice();
            var devMode = new Devmode();
            displayDevice.cb = Marshal.SizeOf(displayDevice);

            NativeMethods.EnumDisplayDevices(null, deviceId, ref displayDevice, 0);
            if (0 != NativeMethods.EnumDisplaySettings(
                    displayDevice.DeviceName, NativeMethods.EnumCurrentSettings, ref devMode))
            {
                int temp = devMode.dmPelsHeight;
                devMode.dmPelsHeight = devMode.dmPelsWidth;
                devMode.dmPelsWidth = temp;
            }

            devMode.dmDisplayOrientation = rotation;

            DisplayChange iRet = NativeMethods.ChangeDisplaySettingsEx(
                displayDevice.DeviceName, ref devMode, IntPtr.Zero,
                DisplaySettingsFlags.CdsUpdateregistry, IntPtr.Zero);
        }
コード例 #4
0
        public void RunFor(int rotation, uint deviceId)
        {
            //uint deviceId = 1; // zero origin (i.e. 1 means DISPLAY2)

            var displayDevice = new DisplayDevice();
            var devMode       = new Devmode();

            displayDevice.cb = Marshal.SizeOf(displayDevice);

            NativeMethods.EnumDisplayDevices(null, deviceId, ref displayDevice, 0);
            if (0 != NativeMethods.EnumDisplaySettings(
                    displayDevice.DeviceName, NativeMethods.EnumCurrentSettings, ref devMode))
            {
                int temp = devMode.dmPelsHeight;
                devMode.dmPelsHeight = devMode.dmPelsWidth;
                devMode.dmPelsWidth  = temp;
            }

            devMode.dmDisplayOrientation = rotation;

            DisplayChange iRet = NativeMethods.ChangeDisplaySettingsEx(
                displayDevice.DeviceName, ref devMode, IntPtr.Zero,
                DisplaySettingsFlags.CdsUpdateregistry, IntPtr.Zero);
        }
コード例 #5
0
 public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref Devmode lpDevMode);
コード例 #6
0
 internal static extern DisplayChange ChangeDisplaySettingsEx(
     string lpszDeviceName, ref Devmode lpDevMode, IntPtr hwnd,
     DisplaySettingsFlags dwflags, IntPtr lParam);
コード例 #7
0
 public static extern int ChangeDisplaySettings(ref Devmode lpDevMode, int dwFlags);
コード例 #8
0
 internal static extern DisplayChange ChangeDisplaySettingsEx(
     string lpszDeviceName, ref Devmode lpDevMode, IntPtr hwnd,
     DisplaySettingsFlags dwflags, IntPtr lParam);
コード例 #9
0
 public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref Devmode lpDevMode);
コード例 #10
0
 public static extern int ChangeDisplaySettings(ref Devmode lpDevMode, int dwFlags);