|
hi all,
does anyone knows where i can find a TextBox that is specialized in inputing the IP address in its format, i saw may controls for that purpose so i guess there are already ones that are created and i don't want to recreate them again.
thanks in advance.
Hercules
|
|
|
|
|
You can use the normal textbox but with validation. FYI, I think .NET 2.0 has a masked textbox with validation built in.
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
I have a opend NetworkStream for Read. If I do Read(buffer, 0, 3) in buffer I have byte[] {49, 13, 10}. But if I create StreamReader to read from NetworkStream function ReadLine awlays return null. All examples that I look at using ReadLine from StreamReader. What can I do? Is it posible because my NetworkStream is opend from Socket not from TcpClient.GetStream()?
And one more question: Because my socket will be opend permanently, how can I implement waiting until data was recieved, using the model above?
|
|
|
|
|
It doesn't matter where the stream comes from, as long as it represents text if you're using a TextReader derivative like StreamReader .
What encoding did you specify? A NetworkStream is a stream of bytes - not characters - and bytes are encoded specificy for different text representations like 7-bit ASCII or 8-bit ASCII with a codepage (ANSI) for a specific system. There's also UTF8 and Unicode, where Unicode is 2 or 4 bytes per character. .NET stores and treats characters internally as UCS-2 (2-byte Unicode).
Also keep in mind that when you read from a stream the cursor (stream position) is advanced so you cannot read that data again from a non-seekable stream (like a NetworkStream , since bytes are being transferred across the net). If you need a non-seekable stream to be seekable you need to cache the data and read-in the cached data, using that to read and seek in the stream.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I want how to fire shortcut keys programatically. How can I make an action for some button event to fire any keyboard shortcut. Let me give you an example:
Suppose we have some button with caption "Button1" that button has a function for his click event called "button1_click", that function should contain the code that I asking for. That code should fire the required keyboard shortcut like (CTRL+C, CTRL+V, CTRL+S,...).
So, if any can help please send me. Summary for what I need is to fire shortcut keys though code programming.
Another point. How can I get the selected text in an opened browser (InternetExplorer) programatically from another application?
Thank You
egyseiko
|
|
|
|
|
For first question you can use:
System.Windows.Forms.SendKeys.Send("^C");
System.Windows.Forms.SendKeys.Send("^V");
System.Windows.Forms.SendKeys.Send("^S");
|
|
|
|
|
I executed that comman for CTRL+C "System.Windows.Forms.SendKeys.Send("^C");" to make copy while I'm selecting some textbox text as for test. Then make paste using CTRL+V but it didn't give me the result for the textbox text. Is that means it didn't fire CTRL+C using "System.Windows.Forms.SendKeys.Send("^C");"
egyseiko
|
|
|
|
|
This code works for me:
copytextbox.Focus();
SendKeys.SendWait("^c");
pastetextbox.Focus();
SendKeys.SendWait("^v");
So , use SendWait() instead of Send() and focus on the control you want before sending shortcut keys.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
is it possible to give relative XML file path so that when a setup is installed on other machines,it fetches XML itself?
private string m_strFileName = "account.xml";
it`s giving error
thanks
|
|
|
|
|
Relative to what? When using the IO classes files are already relative to the application's - not the library in which your code runs - current working directory, not necessary the application's installation directory. You can get the current working directory by getting Environment.CurrentDirectory and the application's installation directory by getting Application.ExecutablePath , passing that to Directory.GetParent .
Depending on what installation technology you're using you can also get the exact path to any file regardless of what type it is. Since you didn't provide any details about what you're trying to do, however, it's impossible to help you.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi! Try this:
private string m_strFileName = ".\\account.xml";
----------------------
Seeing the infinite...
|
|
|
|
|
I have a problem with this code:
------------------------------------------------------------
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct StructA
{
public int MyVariable;
}
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct StructB
{
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 3)]
public StructA[] MyArray; // size must be 3;
}
------------------------------------------------------------
If I take Marshal.SizeOf(StructB) I have this error: Type can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed. So, what can I do to fix the problem?
|
|
|
|
|
There are limitations to marshaling C-style structs in managed code. See Interop Marshaling[^] for details.
You can unroll your structure (or "flatten" it) to make a new structure. This is typically preferred over marshaling structs within structs (which is not supported at all on .NET CF).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heyas all,
I'm kind of confused on this myself, so I'll attempt to explain the best I can, so bare with me
I'm making a cataloging program that reads data from an xml file. The xml file has to obvisiously have a specific format, or at least specific tags to look for to load the correct data into the controls on the windows form. I'm thinking that XmlDocument is the best way to go so I have
<br />
public class XmlData<br />
{<br />
public int CheckForData(string filename)<br />
{<br />
if(!File.Exists(filename))<br />
{<br />
XmlDocument Xdoc = new XmlDocument(nameTable);<br />
}<br />
}<br />
}<br />
This brings up more issues. First and foremost, how do I go about using a NameTable? The user needs to be able to name their file anything, so how do I go about ensuring that the last file used is loaded the next time the program starts, and also, if a file hasn't been previously used, that a new default file is loaded. I've created and added a skeleton xml file that I want the program to use to the project called BlahData.xml. Am I on the right track in anything I'm doing or thinking?
ANY INFORMATION even remotely related to what I'm attempting to accomplish will be most appreciated.
Thanks all,
John
|
|
|
|
|
Hi,
Ill try to break up your requests to little answerable parts :
1. I see no need for you to specify a NameTable for your XmlDocument. Just use the parameterless constructor, when working with XmlDocument.
2. To load the last file used in the next session you will have to store this information somewhere. As I think this wont be the last setting you need to store in your program I would create a configuration file in xml format where you can store any type of information. You could search CodeProject for this part. If I remember right there is at least one implementation around which should make this point easy.
3. To create a skeleton of your xml was no bad idea. Depending on the complexity of its structure you could also create it programmatically, but having a template makes it simpler. You can add the file directly to your assembly as an embedded resource and save it to your desired location with the following code:
<br />
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();<br />
<br />
Stream inputStream = assembly.GetManifestResourceStream("DefaultNameSpaceOfTheProject.FileNameOfTheEmbeddedResource");<br />
FileStream outputStream = new FileStream(newFilePath, FileMode.CreateNew);<br />
byte[] buffer = new byte[1024];<br />
while (true) <br />
{<br />
int read = inputStream.Read(buffer, 0, buffer.Length); <br />
outputStream.Write(buffer, 0, read);<br />
if (read < 1024)<br />
break;<br />
}<br />
outputStream.Close();<br />
inputStream.Close();<br />
This will assure that noone changes your default file once the program is installed.
|
|
|
|
|
Is there a tool that can convert rtf to html? The setup is this, the rtf text will be coming from the DB. The conversion will happen on the server, so i don't have access to the file system; so Word SaveAsHTML won't work.
OK, does someone know of anything?
|
|
|
|
|
A quick search[^] on "rtf to html" yields many, many results and this has been covered many times on this site. Click "Search comments" at the top of this message board to search for additional comments.
Actually you can use Word because Word does not have to load from a persistent file, but can also load from a stream. This is because the Word.Document object implements IPersistStorage (a COM interface) which loads an IStorage object, which you can obtain from P/Invoking OleCreateFromData . This requires interop'ing many native interfaces, like those I mentioned above as well as IDataObject (which is different from .NET's implementation of IDataObject , though they represent the same thing). A good understand of Interoperating with Unmanaged Code[^] is required, and knowledge of COM is very helpful.
This is still not the greatest idea, however, since the Word automation server is not scalable and should typically not be used on the backend of a client/server application.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Since the Word automation server should not be used in the backend of a server application, is there any recomended way of converting Word docs to other formats in a server environment? My app requires uploading documents and manipulating those documents; so supporting a Word format would be very convenient for my users.
Thanks,
Andy
|
|
|
|
|
That's exactly the sort of situation that the Word 2003 XML Schema[^] solves. Your users upload Word 2003 documents saved as XML (and you can automate this using solution files) and you work with pure and rich XML. Send the modified (or original) version back with the right content-type and it works just like an actual document in every way.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
i'm making a 2d sprite game with directx but i can't figure out how to use the alpha channel so that parts of my images are transparent. what is the best type of image to use, .png, .bmp? and how do i apply an alpha channel to them.
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
.bmp does not support alpha channels, nor does .jpg, .gif, or .tiff. .gif only supports an indexed color to serve as a transparency, which is the same as what is done for 24-bit and lower .ico files. .png does support alpha channels. You can find lots of information about image formats by searching the web, but this forum is not the appropriate place for questions not related to using C#. You can also use Image.IsAlphaPixelFormat on each member of the PixelFormat enumeration to see which ones that GDI+ (which .NET uses for the graphics classes) supports support alpha channels.
If you're question is about how to use such images in C# then see the Image class in the .NET Framework SDK. Managed DirectX can also make use of these, as well as native code. Use Bitmap.GetHbitmap to get an IntPtr that represents the HBITMAP (native handle to a bitmap data structure, which describes about any image format) for calls to native APIs that require an HBITMAP .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I am trying to build a general purpose math and graphics class library, but am running into problems because it seems that you can't use graphics classes in a class library unless the library is control-based. But I don't want a control, just some classes and methods for mathematical and graphical calculations. Does anyone out there know how to do this?
Thanks,
Royce
|
|
|
|
|
|
Of course u can, but the class library template does not reference the System.Drawing assembly. U'll have to add that reference manually.
|
|
|
|
|
first let me explain my situation, my room mate and i both have computers and often enough there's something one of us wants to show the other on our screen but we're to lazy to get up and go look. so this is what i would like to do: i would like to grab a window, like internet explorer, and drag it to his desktop so that he can now see the page. or just send the current screen display to his computer.
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|