|
Dear Guys:
I would like to build a GUI-Application(in BCB5) that can "simulate" behavior just like "DOS Prompt", it should also get vertical-scroll bar(can view history command) & Block-Marking for copy function.
>dir
edit.000 0 3-24-04 11:49
edit.001 0 3-24-04 11:49
edit.002 0 3-24-04 11:50
>asdf
Unknown command "asdf"
>x
^cursor blinking here~
Would you please hint me what component I should choose?(MEMO?...)
BR
JP Chou
|
|
|
|
|
And your asking a question about Borland C++ in a Microsoft C# forum why.....?
Your question is much better suited for a Borland Forum.
RageInTheMachine9532
|
|
|
|
|
I'm sorry!I thought the concept/algorithm is the same...
Anyway~Thanks for your remind...
|
|
|
|
|
The problem came in when you asked for components. The components that come with the Microsoft developement environments are different from those that come with Borland's.
But in your case, I don't think the components will be of much use, except for a TextBox anyway. How complex this gets depends on the command set you want your Shell to understand and what you want it to do.
If you want to just pass what is typed in your shell to a command prompt and get information back, that's not too hard for us Microsoft user because we can tap into the standard streams of a console window pretty easily in the .NET world. I don't know that is going to work in Borland's.
If you want to write a replacement for a Console window, you've got a lot of work ahead of you. Parsing command lines, executing other programs, any batch commands and scripting, ...
It all depends on what you want it to do...
RageInTheMachine9532
|
|
|
|
|
HI,
I can't find out the end of line in C#. It's like chr(13) in VB. Anybody helps me?
My project is: I want to display a text file in RichTextBox. Then, I want to capture all the text to fill in a text box. And I want to replace the end of like by ";".
Thank a lots
Don't smile at me if silly question, 'cos I'm a beginner to C#
|
|
|
|
|
Are you looking for the "\n" or System.Environment.NewLine ?
----------------------------------------------------------------------
T Manjaly
C# Tutorials and samples : http://www.dotnetspider.com
|
|
|
|
|
Thank you!That's right.
txtString=txtString.Replace("\n",";");
|
|
|
|
|
i am doing my final year project on remote desktop control.Till now i have captured the image of remote desktop.Now i want to control it remotely.tell me some functions to do this.I want to do this in C#. As I am doing my hole project in C#
mughalali
|
|
|
|
|
Simply capture the screen coordinates of the mouse click and translate those through to the remote desktop.
Honestly, though, .NET is far too high-level at this point for an effective remote desktop application. Terminal services - which RDP uses - actually uses a virtual frame buffer that "intercepts" the output destined for the graphics card and displays that in your remote client. So if a program were to draw a simple line, that line would be drawn to the virtual frame buffer instead of having to grab an entire screenshot in a loop. Using this much more efficient approach requires low-level code and a lot of functionality in the Microsoft DDK. While it may be possible to P/Invoke what you need, there would be a LOT to do. If you're serious about carrying this project through, you should take a look at this approach that the major commercial solutions use.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please if u can tell me some functions in Microsoft DDK to achieve my goal,or tell me some book for this article.
|
|
|
|
|
Sorry, but this is not an area I venture into. Just download the DDK and look over the docs. You might also check-out some open source implementations of similar protocols at http://freshmeat.net[^] or something along those lines.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All,
Does anybody of you know how to get distinct rows from DataView or DataTable.
Thanks
Ruchi
|
|
|
|
|
The best way is to use the DISTINCT keyword in your SQL statement that fills the DataSet (which contains the DataTable ) or the DataTable , but if for some reason you can't you could try a couple different ways.
The default implementation does support getting distinct values as a simple method call, but you could either sort the DataView , enumerate it and skip adjacent duplicates; or keep a look-up table of what you've already enumerated and compare that as you enumerate your DataTable . In most cases, the former method would be faster and would consume less space.
If you use a look-up table, consider a Hashtable with the distinct field as the key and a reference to your DataRow as the value (it'll be a reference, not a copy, making retrieval faster...unless you clone).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
HI,
Similar to what you suggested, I got an article on Microsoft website. It works but the limitation is what if DISTINCT is to be applied on multiple columns
http://support.microsoft.com/default.aspx?scid=kb;en-us;326176
Add the following Private method to the class definition. This method is the same as the method that is used in other DataSetHelper articles. It is used to compare field values (including NULL).
private bool ColumnEqual(object A, object B)<br />
{<br />
<br />
<br />
if ( A == DBNull.Value && B == DBNull.Value )
return true; <br />
if ( A == DBNull.Value || B == DBNull.Value )
return false; <br />
return ( A.Equals(B) );
}
Add the following Public method to the class definition. This method copies unique values of the field that you select into a new DataTable. If the field contains NULL values, a record in the destination table will also contain NULL values.
public DataTable SelectDistinct(string TableName, DataTable SourceTable, string FieldName)<br />
{ <br />
DataTable dt = new DataTable(TableName);<br />
dt.Columns.Add(FieldName, SourceTable.Columns[FieldName].DataType);<br />
<br />
object LastValue = null; <br />
foreach (DataRow dr in SourceTable.Select("", FieldName))<br />
{<br />
if ( LastValue == null || !(ColumnEqual(LastValue, dr[FieldName])) ) <br />
{<br />
LastValue = dr[FieldName]; <br />
dt.Rows.Add(new object[]{LastValue});<br />
}<br />
}<br />
if (ds != null) <br />
ds.Tables.Add(dt);<br />
return dt;<br />
}
|
|
|
|
|
Yes, all they're doing here is implementing a custom IComparer with which to sort (not really necessary in most cases since two columns with DBNull.Value would still have the same value, but whatever).
The only good way to do this is to use the DISTINCT keyword in your SQL statement. What's wrong with that?
It's either that, or use look-up tables which could be very expensive, especially with large data sets.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
the following are my classes
Class Students.cs
<br />
using System;<br />
using System.Collections;<br />
using System.IO;<br />
using System.Runtime.Serialization;<br />
using System.Xml.Serialization;<br />
namespace WindowsApplication1<br />
{<br />
[Serializable]<br />
public class Students<br />
{<br />
int index = 1;<br />
ArrayList students = new ArrayList();<br />
public Students()<br />
{<br />
}<br />
<br />
<br />
public void AddStudent( string name, string add)<br />
{<br />
Student t = new Student(index++, name, add);<br />
students.Add(t);<br />
}<br />
public void RemoveStudent(int sID)<br />
{<br />
foreach(Student s in students)<br />
{<br />
if (s.StudentID == sID)<br />
{<br />
students.Remove(s);<br />
return;<br />
}<br />
}<br />
return;<br />
}<br />
<br />
public ArrayList Items<br />
{ get {return students;} }<br />
<br />
public Student this[int index]<br />
{<br />
get<br />
{<br />
foreach(Student s in students)<br />
{<br />
if(s.StudentID == index)<br />
return s;<br />
}<br />
return null; <br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
Class Student.cs
using System;<br />
using System.IO;<br />
using System.Runtime.Serialization;<br />
using System.Xml.Serialization;<br />
namespace WindowsApplication1<br />
{<br />
[Serializable]<br />
public class Student<br />
{<br />
private int intStudentID = 0;<br />
private string strName = "";<br />
private string strAddress = "";<br />
<br />
public Student(){}<br />
public Student(int sID, string n, string a)<br />
{<br />
StudentID = sID;<br />
Name = n;<br />
Address = a;<br />
}<br />
public int StudentID<br />
{<br />
get{return intStudentID;}<br />
set{intStudentID = value;}<br />
}<br />
public string Name<br />
{<br />
get{return strName;}<br />
set{strName = value;}<br />
}<br />
public string Address<br />
{<br />
get{return strAddress;}<br />
set{strAddress = value;}<br />
}<br />
}<br />
}<br />
The following is the code that I have used to attempt to serialize the class.
StreamWriter w = null;<br />
try<br />
{<br />
XmlSerializer ser = new XmlSerializer(typeof(Students));<br />
w = new StreamWriter("class.xml");<br />
ser.Serialize(w, Hstudents);<br />
}
catch (Exception ex)<br />
{<br />
string strErr = String.Format("Unable to serialize class, error '{0}'",<br />
ex.Message);<br />
MessageBox.Show(strErr,"Serialize Error",MessageBoxButtons.OK,<br />
MessageBoxIcon.Error);<br />
}
finally<br />
{<br />
if (w != null) w.Close();<br />
w = null;<br />
}
If i change it to work with binary serialization, the serialization works fine. Is there somethign special that i have to do to the classes to get it to serialize correctly?
|
|
|
|
|
First of all, using a binary formatter implies you're using runtime serialization. Runtime serialization and XML serialization are COMPLETELY different monsters. Don't confuse the two. You can read more about the differences by reading Serializing Objects[^] in the .NET Framework SDK. Also, binary and SOAP serialization are in the System.Runtime.Serialization (and child) namespaces, while XML Serialization is in System.Xml.Serialization .
To answer your question, though, take a look at the XmlArrayAttribute and the XmlArrayItemAttribute that you'd use both on your ArrayList property.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey all, I've been working on a wrapper for the WindowsXP Peer-to-Peer sdk for a while now in my free time and I've just completed an initial release of it with enough functionality to create and maintain networks between peers. I'm working on a .Net wrapper because the API is basically written in C and looks clunky in .Net applications. Anways, I'd like to write an article about it for Code Project, but would like some input from people and find out if anyone is having any problems with it. If you know what the WinXP P2P SDK is, then that's great and you should have no problem using this wrapper, otherwise you may have some issues, but hopefully my explanation of how to use it is good enough. Here's the link to the WinP2P.Net (what I've called it so far):
WinP2P.Net[^]
Here's a link to MS's info on what they've done with the API:
Windows XP P2P SDK From Microsoft[^]
Anyways, I hope you all can use this and it works well for you, if not, send me an email or post a message on the forums on the WinP2P.Net site, I check those quite often. Thanks in advance and good coding!! Oh yeah, I've never attempted anything really of this scale, so bear with the bugs that may be in there, I'll do what I can to get them fixed as soon as possible
Jason Schneekloth
|
|
|
|
|
Sounds like it would be an interesting article. I'll give this a try later.
One thing I might mention - especially being a CodeProject editor - is that it is ".NET", not ".Net". This is a common mistake but is not proper. ".net" is also not allowed in images (i.e., logos) as it is reserved for Microsoft use only. Technically, you're not even supposed to use ".NET" in your product naming, but you're not a commercial solution so it's not like they can do much (although look at "MikeRoweSoft"). Just a heads-up.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ack! I didn't know that. Hehe, looks like there's gonna be a change in what it's called. Thanks for the head's up
|
|
|
|
|
Ya but all he did was hand over the domain and he got loads of free stuff !
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Heath Stewart wrote:
is that it is ".NET", not ".Net". This is a common mistake but is not proper. ".net" is also not allowed in images (i.e., logos) as it is reserved for Microsoft use only.
.net is an internet root domain, and no-one can tell me how to spell it.
top secret
|
|
|
|
|
If, for some reason, you were having issues with getting the Advanced Networking Pack installed and started, there are updated instructions in the manual and also in the forums under tech support for WinP2P.
|
|
|
|
|
Thanks to this great site and the great people contributing source code examples, I've managed to create my first C# application! woot woot woot!
The only problem I'm having is that my application launches internet explorer for every url that I click on (from a list of urls). Instead of having a new instance of internet explorer started everytime, is there a way to find an existing instance of iexplorer and change it's url?
Currently, I can find an existing instance of iexplorer bring it to the foreground via "SetForegroundWindow" in user32.dll, but I don't know how to change it's url?
Can anyone help me on this?
Thanks.
Chris.
|
|
|
|
|
One way is to simply use ShellExecute. The default implementation in windows is to use a running instance of Internet Explorer (or whatever the default browser is, which is often the preferred way anyway):
ProcessStartInfo info = new ProcessStartInfo(url);
info.UseShellExecute = true;
Process.Start(info); You can also use the InternetExplorer out-of-process server if you want to force the user to use IE. This represents the fore-most instance of IE. First create an interop assembly of Internet Explorer by either typing the following:
tlbimp.exe /out:Interop.SHDocVw.dll %WINDIR%\system32\shdocvw.dll Or using VS.NET to add a COM reference to the "Microsoft Internet Controls" (shdocvw.dll). Then create an instance of the InternetExplorerClass like so:
InternetExplorerClass ie = new InternetExplorerClass();
object url = url;
object missing = Missing.Value;
ie.Navigate2(ref url, ref missing, ref missing, ref missing, ref missing); See Programming and Reusing the Browser[^] for more details.
If you want to host the WebBrowser control (the control that is actually IE, which also hosts MSHTML, the Microsoft HTML rendering engine), you can additionally run:
aximp.exe /out:AxInterop.SHDocVw.dll %WINDIR%\system32\shdocvw.dll to create an ActiveX host for the WebBrowser control (by default, named AxWebBrowser ), which you can host in your forms and container controls. You can find more information about this in the link above (related to the COM interfaces exposed by WebBrowser and MSHTML). There's also several articles here on CodeProject that described advanced hosting using .NET. Just search (a good query term is "IDocHostUIHandler").
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|