|
Wow - what a terrible design. Your teacher is an idiot.
You can certainly do this as a console application, and doing so would free you from having to write GUI code.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
Wow - what a terrible design. Your teacher is an idiot.
5
|
|
|
|
|
It was a funny statement, but what's not funny is how often that's true!
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Since he's asking that you load the data in "main" or globally (which you would still have to do in "main" or in a callee), he most likely expects you to write a console application.
This is possible to do in C#, yes. I would recommend you take a look at the system.Convert class (to easily convert data types), the System.IO.FileStream and System.IO.StreamReader classes (if reading from a file), as well as the rest of the .NET Framework SDK.
For class projects (and we're typically pretty good about detecting them in this forum), you won't find all the answers - you won't learn anything that way. If you have specific questions regarding certain functionality, feel free to ask.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I need to get a highlighted text from a window (e.g IE) and put it in a textbox in my application.
I want to use a hot key combination (e.g Ctrl + 1) to move the text.
My hot key combination should function like Ctrl + C, but I don't want to get the text from the clipboard.
The code for the hotkey combination I know, but not how to get the highlighted text from a other window.
Is it anyone who know how to do this?
|
|
|
|
|
There is no universal way. Internet Explorer and other Microsoft COM servers (like Word) use a TextRange object. From Internet Explorer - if you have a reference to the current IHTMLDocument2 , you can create a TextRange by using IHTMLDocument2.selection to get an IHTMLSelectionObject , and if not null call IHTMLSelectionObject.createRange . The process is similar for Office products, but uses Office-specific objects to get a TextRange (a different class but works the same).
For text boxes and rich edit controls (encapsulates by the TextBox and RichTextBox controls, but are just Windows Common Controls classes "EDIT" and "RichEdit" (1.0), "RichEdit20A" (2.0; ANSI), or "RichEdit20W" (2.0; Unicode), you can P/Invoke SendMessage and pass EM_GETSEL (or EM_GETSELTEXT for Rich Edit controls - both work but work differently) to the control's HWND (exposed by the Control.Handle property inheritted by each control in Windows Forms).
If this is from another application to which you don't have a reference (or handle), P/Invoke FindWindow and/or FindWindowEx . This process has been discussed many times in this forum so click "Search comments" for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for the answer.
Can you give me a example on how to P/Invoke SendMessage and pass EM_GETSEL?
|
|
|
|
|
I would recomend you search for "SendMessage" by clicking "Search comments" directly above this forum. We've covered it more times than I can count here, and there are plenty of examples found in articles on this site.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I'm sorry but I don't understand how to use the EM_GETSEL or the EM_GETSELTEXT. Can you point me in the right direction?
Here is my code so far:
private string gst(IntPtr hwnd)
{
IntPtr retValue;
StringBuilder strb = new StringBuilder(4096);
retValue = SendMessage(hwnd, EM_GETSELTEXT, (IntPtr)0, out strb);
return strb.ToString();
}
|
|
|
|
|
This may be an old topic but I'm having trouble finding any decent information on how to send SNMP traps using C#. Any help/links would be appreciated.
|
|
|
|
|
http://www.google.com/search?q=%22SNMP+traps%22+C%23[^]
Several of those results even point back to CodeProject. Click "Search comments" to search this forum (which isn't currently indexed by web crawlers).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I know this is a long time after the original thread, but i'm still a little lost on the subject......basically what i'm trying to do is make a computer act as an agent and generate traps, that's all.
Is it possible to do this using the winsnmp functions .ie. SnmpCreatePdu,SnmpSendMsg, etc?
Thanks
|
|
|
|
|
This is really an ASP question, but since I'm using C#, I'll post it here. I'm having trouble accessing remote files (or directories) out of my application. I simply want to check if a file exists on the other machine, which is shared on the same network. No dice, always comes up false. I have set up the IUSR_ComputerName and IWAM_ComputerName accounts on the remote computer to match my IIS account. Still returns only false. I've mapped a drive to the network location, and then put that mapped drive into a virtual directory. In the IIS Administrator I can see the files I'm trying to reach through this virtual directory...but the application only returns false.
Here's the code from my application:
<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
if (System.IO.Directory.Exists("Drive"))<br />
Response.Write(Server.MapPath("Drive") + " Exists<br>");<br />
else<br />
Response.Write(Server.MapPath("Drive") + " does not exist<br>");<br />
}
Thanks for the help on this. If anybody knows another method of accomplishing this same task, I'm all ears. All I can report is that we don't want to run IIS on the remote machine, and we don't particularly want to spawn an application to take care of the file maintenance...we'd like for the code to handle it.
|
|
|
|
|
What is Drive ? in if (System.IO.Directory.Exists("Drive"))
Please substitute "Drive" as "x:\\" should work..( where x is mapdrive letter)
or
if (System.IO.Directory.Exists("\\\\MachineName\\ShareName\\FolderName")) should do
Sandeep Naik
|
|
|
|
|
Drive is the name of my virtual directory, which maps to what you call x:
|
|
|
|
|
As Sandeep correctly mentioned, you're looking for the wrong directory.
You need to wrap "Drive" in a call to Server.MapPath() as well when calling System.IO.Directory.Exists(), otherwise you're actually searching for a Direcory named "Drive" instead of the mapped one.
Regards,
mav
|
|
|
|
|
Hi,
I am a writing a program in which a user can open a file in some application by creating a new instance of that application. But what I want to do is see if that application is already open (the user opened it not through my program, but by double clicking the application icon) in which case use the already open application to display the file instead of creating a new instance.
How can I do it.
Thanks
|
|
|
|
|
One way to do this
if ( System.Diagnostics.Process.GetProcessesByName("processname").Length == 0 )
MessageBox.Show("Process not running");
else
MessageBox.Show("Process is running");
Sandeep Naik
|
|
|
|
|
Mr. Sandeep,
I guess you got the question wrong. Once I find that a application is already open, Is there a way that i can open a file in that, instead of creating a new instance of the application and then opening a file.
Thanks
|
|
|
|
|
There is, and a simple search for single instance application[^] would return several results, including Single Instance Application in VB.NET[^], which should be easy enough to translate (it's mostly calls to the BCL).
You can also communicate with the first instance through .NET Remoting - the preferred method - or native RPC, named pipes, DDE, or many other ways (but those are all native, which requires extra code in order to call necessary APIs).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I'm assuming it's the .NET Framework V2.0 beta - am I right?
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
|
Hello All
My question is this that how to embed a flash movies on a form? I'm using Macromedia Flash Obejet (A COM(+) control. I 'm the path of Movie in Movie property but it's not showing can any body helo me what to doo how to set properties plzzzzz. I'll be very thankful.
Cheers Bye
Rizwan Ahmed
|
|
|
|
|
Have you tried using acimp utility in the frameworks BIN folder on the activeX component, it should produce .net assemblies for you to use with your app.
|
|
|
|
|
There's samples on this website. I'm pretty sure. Do a search.
/\ |_ E X E GG
|
|
|
|