|
Good point, definitely a win
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
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;
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;
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!");
DEVMODE dm = new DEVMODE();
dm.dmSize = (short)Marshal.SizeOf(dm);
dm.dmPelsWidth = 1024;
dm.dmPelsHeight = 768;
dm.dmBitsPerPel = 32;
dm.dmDisplayFrequency = 60;
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);
}
}
|
|
|
|
|
Hi,
DEVMODE is a complex structure, and changing a display settings requires a valid combination of all the parameters, which isn't easy to come up with, unless you ask the system for the current settings first, then change what you want changed. So I recommend you call EnumDisplaySettings, modify the result, and only then call ChangeDisplaySettingsEx.
Also chances are you are not allowed to change too many parameters at once.
BTW: I did not check your struct; the slightest mistake in its definition would be fatal!
Suggestion: try and check the dmSize field; I would expect the value to be available somewhere on the Internet...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hello,
I have a windows application with datagrid. I want the user to select data he wants from the datagrid, click a button and it will copy this data in table format to clipboard. Then if the user wants he could paste this data in Word for example (as table)
|
|
|
|
|
You have a problem with ctrlC and ctrlV, these work. Otherwise you need to load the structure into the clipboard, probaly as tab delimited strings. Pasting into excel works, creating a table in word may be a bit of a challenge!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi,
How i can send and recieve data with modem?
for example send and recieve a Image.
tanks
|
|
|
|
|
|
mehdi rahimzade wrote: How i can send and recieve data with modem?
for example send and recieve a Image.
Hi Mehdi,
You cannot just do that without having an internet connection, could you? Just buying a Modem and requesting it for Data processing with your hands joined together wont help. Besides, Modem are used to send and recieve data. How can you ask such a worthless question in this forum? And what has this got to do with programming????!!!! I wonder!
Search google before posting such annoying posts here,
Rajdeep.NET
|
|
|
|
|
I Search in Internet but not found Good Answer for this!
i need to sample or code or article for sending and recieveing data with programing in C#.NET Like Hyper Terminal in WINDOWS.
|
|
|
|
|
Do you seriously feel comfortable attacking someone for allegedly asking a stupid question? Have you heard the expression "the pot calling the kettle black"?
|
|
|
|
|
I don't know if you've heard this phrase:
"It is better to remain silent, and be thought a fool, than to speak out and confirm it."
but you should think about it.
This is, honestly, meant to be kind advice.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
No ,I want send data in win application Program with modem betwin same Computer.
|
|
|
|
|
Wait, you want to use a modem to send data from a windows application running on your computer so that the data sent is received back on the same computer. There are no other computers involved?
If that is the case, why do you need a modem at all? There are many ways for data to be exchanged between processes on the same computer, or even within the same process.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
I very very need to this!
Please Help Me...
|
|
|
|
|
If you really need something, a forum where people help for free is not a good choice. Place an ad in the jobs section for someone to write it for you.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I am a little confused as to what your are trying to do. If I read your replies right then you want a PC, with two serial ports, each connected to a modem. The two modems are connected together (presumably via two telephone lines, or else you will need a null phone connection with a battery.
You then want to transfer files from the PC to the PC via the modems? If so, then odd, but do-able.
I would just eliminate the modems and use a null-modem cable if there was a good reason for this.
Talking to the modems: http://www.atarimagazines.com/compute/issue131/33_talktoyourmodem.php[^]
Try it using two Hyperterminals on separate com ports and you should see what is happening (and if all the H/W is working).
Then in C#, you will need two instances of the SerialPort class to replace the hyperterminals.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
Take a look at the documentation for the ToolTip control. You don't even need to look at the individual methods/properties, the summaries give enough information.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
I haven't had that problem.
You did a release build?
You made an installer that:
Includes the "primary output" of the application project?
Creates the file association?
Then installed on the target system (which has .net) and it doesn't work?
|
|
|
|
|
|
I left my computer unatended and my little cousin decided he wanted to delete my message and make a bad vote. I sincerely apologise to everyone. My bad.
|
|
|
|
|
|