Click here to Skip to main content
15,910,981 members
Home / Discussions / C#
   

C#

 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 12:32
harold aptroot9-May-09 12:32 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
Christian Graus9-May-09 12:38
protectorChristian Graus9-May-09 12:38 
AnswerRe: Preferred way of bytes to kbytes conversion? Pin
Luc Pattyn9-May-09 12:37
sitebuilderLuc Pattyn9-May-09 12:37 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 12:41
harold aptroot9-May-09 12:41 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
Luc Pattyn9-May-09 12:59
sitebuilderLuc Pattyn9-May-09 12:59 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 13:06
harold aptroot9-May-09 13:06 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
Luc Pattyn9-May-09 13:09
sitebuilderLuc Pattyn9-May-09 13:09 
GeneralEnabling Secondry Monitor using C# Pin
jonesyx9-May-09 9:24
jonesyx9-May-09 9:24 
Hi,

Ive been trying to build a program to automate the steps to enable a secondry monitor and extend my desktop in C#.

Found this article however it was left open.
http://stackoverflow.com/questions/233411/how-do-i-enable-a-second-monitor-in-c/233584[^]

My current progres is using the code below however it dosent work. It returns a -1 error flag.

Any help would be greatly appreciated.
Thanks
Michael

[DllImport("user32.dll")]
static extern int ChangeDisplaySettingsEx(string lpszDeviceName,
   ref DEVMODE lpDevMode, IntPtr hwnd, uint dwflags, IntPtr lParam);



[StructLayout(LayoutKind.Sequential)]
			public struct DEVMODE
			{
			     public const int CCHDEVICENAME = 32;
			     public const int CCHFORMNAME   = 32;
			
			     [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHDEVICENAME)]
			     public string dmDeviceName;
			     public short  dmSpecVersion;
			     public short  dmDriverVersion;
			     public short  dmSize;
			     public short  dmDriverExtra;
			     public int    dmFields;
			
			     public short  dmOrientation;
			     public short  dmPaperSize;
			     public short  dmPaperLength;
			     public short  dmPaperWidth;
			
			     public short  dmScale;
			     public short  dmCopies;
			     public short  dmDefaultSource;
			     public short  dmPrintQuality;
			     public short  dmColor;
			     public short  dmDuplex;
			     public short  dmYResolution;
			     public short  dmTTOption;
			     public short  dmCollate;
			     [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHFORMNAME)]
			     public string dmFormName;
			     public short  dmLogPixels;
			     public int    dmBitsPerPel;    // Declared wrong in the full framework
			     public int    dmPelsWidth;
			     public int    dmPelsHeight;
			     public int    dmDisplayFlags;
			     public int    dmDisplayFrequency;
			
			     public int    dmICMMethod;
			     public int    dmICMIntent;
			     public int    dmMediaType;
			     public int    dmDitherType;
			     public int    dmReserved1;
			     public int    dmReserved2;
			     public int    dmPanningWidth;
			     public int    dmPanningHeight;
			
			     public int    dmPositionX; // Using a PointL Struct does not work 
			     public int    dmPositionY;
			
				}
			
		public static uint CDS_RESET = 0x40000000;
        public const int CDS_UPDATEREGISTRY = 0x01;


public static void Main(string[] args)
		{
			Console.WriteLine("Hello World!");
			
			// TODO: Implement Functionality Here
						
			DEVMODE dm = new DEVMODE();
			dm.dmSize = (short)Marshal.SizeOf(dm);
			dm.dmPelsWidth = 1024;
			dm.dmPelsHeight = 768;
			dm.dmBitsPerPel = 32;
			dm.dmDisplayFrequency = 60;
			//dm.dmFields = DevModeFields.DM_BITSPERPEL | DevModeFields.DM_PELSWIDTH | DevModeFields.DM_PELSHEIGHT | DevModeFields.DM_DISPLAYFREQUENCY;
			int res = ChangeDisplaySettingsEx(@"\\.\DISPLAY2", ref dm, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero);
			Console.WriteLine("result = " + res.ToString());
			
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}

GeneralRe: Enabling Secondry Monitor using C# Pin
Luc Pattyn9-May-09 12:29
sitebuilderLuc Pattyn9-May-09 12:29 
Questiondatagrid copy Pin
michaelgr19-May-09 7:44
michaelgr19-May-09 7:44 
AnswerRe: datagrid copy Pin
Mycroft Holmes9-May-09 14:32
professionalMycroft Holmes9-May-09 14:32 
Questionsend and recieve data with modem Pin
mehdi rahimzade9-May-09 4:31
mehdi rahimzade9-May-09 4:31 
AnswerRe: send and recieve data with modem Pin
Mohammad Dayyan9-May-09 5:42
Mohammad Dayyan9-May-09 5:42 
AnswerRe: send and recieve data with modem Pin
Rajdeep.NET is BACK9-May-09 6:46
Rajdeep.NET is BACK9-May-09 6:46 
GeneralRe: send and recieve data with modem Pin
mehdi rahimzade9-May-09 8:18
mehdi rahimzade9-May-09 8:18 
GeneralRe: send and recieve data with modem PinPopular
scottgp9-May-09 8:46
professionalscottgp9-May-09 8:46 
GeneralRe: send and recieve data with modem Pin
Henry Minute9-May-09 9:58
Henry Minute9-May-09 9:58 
AnswerRe: send and recieve data with modem Pin
mehdi rahimzade9-May-09 8:13
mehdi rahimzade9-May-09 8:13 
GeneralRe: send and recieve data with modem Pin
Colin Angus Mackay9-May-09 13:03
Colin Angus Mackay9-May-09 13:03 
AnswerRe: send and recieve data with modem Pin
mehdi rahimzade9-May-09 9:46
mehdi rahimzade9-May-09 9:46 
GeneralRe: send and recieve data with modem Pin
Christian Graus9-May-09 11:12
protectorChristian Graus9-May-09 11:12 
AnswerRe: send and recieve data with modem Pin
OriginalGriff9-May-09 22:52
mveOriginalGriff9-May-09 22:52 
Question[Message Deleted] Pin
hkjghkj19-May-09 4:02
hkjghkj19-May-09 4:02 
AnswerRe: ToolTip Pin
Henry Minute9-May-09 7:07
Henry Minute9-May-09 7:07 
Question[Message Deleted] Pin
jas0n239-May-09 3:13
jas0n239-May-09 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.