|
In VC#.net, When Enter Key was been pressed, System warnning sound was been played. How do stop it at programm.
|
|
|
|
|
In Form's KeyDown and KeyPress events,Can do it.
private bool bEnter = false;
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
bEnter = false;
if (e.KeyCode == Keys.Enter && this.ActiveControl != fpSpread5)
{
bEnter = true;
}
}
private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (bEnter)
{
e.Handled = true;
SendKeys.Send("{TAB}");
}
}
|
|
|
|
|
old way use resource file,now how to use xml ?
could you tell me?
|
|
|
|
|
You are right: New way is XML. Use a resx file. Visual Studio has inbuild support. Just set "Use Local Resource" or something like that, in the properties of the Form.
Cheers,
Richard Schneider
|
|
|
|
|
hi Richard,i know how to use resx file.but i dont know how to use xml to achieve my idea , are you know ? please tell me.
|
|
|
|
|
You will have to tell me your idea, before I can help you to achieve it.
I nice thing about a XML resx files is that they are real easy to parse. In theory, an app can be developed to read resx, call google translate and provide you with localised resx files!
Cheers,
Richard Schneider
|
|
|
|
|
ResX files are XML files, and you can even store binary data in a ResX file so long as you encode it in a manner that the ResXResourceReader (or whatever reader you configure) understands, like base64 (which is most common for binary data).
You should read Developing World-Read Applications[^] for a good overview of localizing and globalizing applications, especially the section Resources in Applications[^]. This describes a lot of information with links to classes you should read.
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 folks,
I am trying to use this freakin old dll. I am new to this so i better ask question one by one.
Starting from struct.
the original struct looks like this:
typedef struct rfreaderstruct RFReader;
struct rfreaderstruct {
HANDLE fh;
OVERLAPPED in_ov;
OVERLAPPED out_ov;
unsigned char buffer[BUFSIZ]; /* Read buffer */
int bufferPoint; /* Number of bytes used from inBuf */
int bufferCount; /* The number of bytes in inBuf */
char nonCommandBuffer[BUFSIZ];
int nonCommandBufferPoint;
int nonCommandBufferEnd;
int mode;
int requestInProgress;
int requestOutProgress;
int pendingWrite;
int pendingRead;
RFMessage rfmsg;
int responseState;
unsigned int responseDataCount;
RFReader *next;
};
Overlapped and RFMessage are just plain struct which i am sure i got it right.
I converted it to this:
[StructLayout( LayoutKind.Sequential )]
internal struct RFReader
{
public const int BUFSIZ = 1000;
internal long fh;
internal OVERLAPPED in_ov;
internal OVERLAPPED out_ov;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=BUFSIZ)]
internal string buffer; /* Read buffer */
internal int bufferPoint; /* Number of bytes used from inBuf */
internal int bufferCount; /* The number of bytes in inBuf */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=BUFSIZ)]
internal string nonCommandBuffer;
internal int nonCommandBufferPoint;
internal int nonCommandBufferEnd;
internal int mode;
internal int requestInProgress;
internal int requestOutProgress;
internal int pendingWrite;
internal int pendingRead;
internal RFMessage rfmsg;
internal int responseState;
internal uint responseDataCount;
[MarshalAs(UnmanagedType.LPStruct)]
internal RFReader next;
}
I got error on the last line, because this struct is like a linked-list node.
How can i get around this problem?
any help would be greatly appreciated.
|
|
|
|
|
Declare next as IntPtr, and use Marshal.PtrToStructure when you need the structure.
<br />
[StructLayout( LayoutKind.Sequential )] <br />
internal struct RFReader<br />
{<br />
...<br />
...<br />
internal IntPtr next;<br />
}<br />
<br />
RFReader reader = (RFReader)Marshal.PtrToStructure(rfreader.next, typeof(RFReader));<br />
<br />
IntPtr unmanagedBlock = Marshal.AllocHGlobal( Marshal.SizeOf(RFReader) );<br />
Marshal.StructureToPtr(nextReader, unmanagedBlock, true);<br />
rfreader.next = unmanagedBlock;<br />
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hi Corinna thanks for the response.
The functions typically look like the following:
RFReader *rfOpenReader( const char *dev, int mode );
void rfCloseReader( RFReader *r );
void rfSetPortBaud( RFReader *reader, int setbaud );
can you show me how to declare it under DllImport?
Thanks,
|
|
|
|
|
frOpenReader:
//un-marshal the RFReader from the IntPtr
[DllImport("anything.dll")]
private static extern IntPtr rfOpenReader(String dev, Int32 mode);
rfCloseReader:
//Both declarations are valid.
//You may try the second one, but without any guarantee.
[DllImport("anything.dll")]
private static extern void rfCloseReader(IntPtr r);
[DllImport("anything.dll")]
private static extern void rfCloseReader(RFReader r);
rfSetPortBaud:
[DllImport("anything.dll")]
private static extern void rfSetPortBaud(IntPtr reader, Int32 setbaud);
[DllImport("anything.dll")]
private static extern void rfSetPortBaut(RFReader reader, Int32 setbaud);
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hi Corinna,
Thanks for the help.
I am totally new on this one. I cannot make it to work though.
Once I declare the functions, I don't quite know how to call those functions for now
For example to use rfOpen, in my C# function I write it like this:
public void rfOpenReader ()
{
string READER_DEVICE = "COM9";
reader = (RFReader)Marshal.PtrToStructure(rfOpenReader( READER_DEVICE, RF_MODE_NONBLOCKING ), typeof(RFReader));
}
is this the way to do it?
I got null exception.
Thanks,
|
|
|
|
|
Hi guys
I invoke statusbar.Refresh() method. I think it should call statusbar's "DrawItem" event sequently. But it doesn't. Why? By the way, other controls seem to have similar cases.
Thanks a lot.
vigorous
|
|
|
|
|
Hey Guys
Does anyone know how Microsoft come up with the colors they use in Office 2003 that are consistent with the selected color scheme when using the Windows XP Style buttons/windows.
The only way i've been able to mimic them is to take screen shots and work the colors out from that, not very scientific!
Any ideas greatly appreciated.
Thanks
Tom
|
|
|
|
|
|
Yea, I'm using it to determine the actual colour scheme in use, and changes, but it does not contain the colors that Office Uses. I have a feeling they are hard coded into Office but I want to confirm.
Thanks
Tom
|
|
|
|
|
hi all!
I have a problem but i don't know reason why. My datagrid somtimes display an red X shape in my application. I don't know how to fix. Can you help me for this problem?
Thank you very much!
Đào Ngọc Hào! Hi How Are You?
|
|
|
|
|
The red X gives us the clue that your using the ASP.NET version in a webpage. Your question would be better handled in the ASP.NET Forum, not the C# Forum.
In either case, this usually means that there is a problem with the properties your set in the DataGrid or there is a problem with the DataSet you bound the grid to.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I think I've posted it correctly because my problem happened in window application, not in asp.net. Anyway your anwser is good. Do you know something else about my problem ? Or it's the same answer which you've posted.
Finally, Thank you for your helping!
Nguyen Thanh Tu
Đào Ngọc Hào! Hi How Are You?
|
|
|
|
|
Without seeing your code, there's nothing we can tell you about the problem, other than "there's a problem!"
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It is a memory error. When you do something, For example,
public ArrayList GetResult()
{
ArrayList list = new Arraylist();
list.Add("1");
list.Add("2");
ArrayList list1 = new Arraylist(); list1 = list;
list.Clear();
return list1;
}
In C#, It will tirgger a memory error.
|
|
|
|
|
Another idea:
Are you using custom ColumnStyles? If yes one of those could have errors in its Paint method.
|
|
|
|
|
Hi everyone,
I'm having a strange problem with DES encryption in .NET (DESCryptoServiceProvider). I'm using 3 implementations of DES, one in .NET, another in JavaScript and one in Java.
I'm encrypting the same short string with the same 8-byte key, using ECB mode. ALl implementations will return a 16-byte cipher text (two 64 bit blocks). The problem is that the first 64-bit block of the cipher text is the same for all three implementations, but the second 64-bit block is different in C#. THe same thing happens when using CBC with initialization vector.
I don't think that there is a problem with my C# code, another C# sample I have tried returned the same results, but here is the code I'm using. I have no clue what to do
MemoryStream memStream=new MemoryStream(100);
DES des=new DESCryptoServiceProvider();
des.Mode=CipherMode.ECB;
CryptoStream encStream = new CryptoStream(memStream, des.CreateEncryptor(desKey, desIV), CryptoStreamMode.Write);
encStream.Write(Encoding.UTF8.GetBytes(strMessage), 0, strMessage.Length);
encStream.Close();
byte[] desEncrypted=memStream.GetBuffer();
string strEncrypted=BitConverter.ToString(desEncrypted, 0, i);
memStream.Close();
Thanks for any ideas in advance,
Rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
OK I figured that out. This is so ridiculous, and it happens to me all the time. I spent at least 2 hours with it yesterday in the evening, and now I post a question to the C# forum and voila, in the next 5 minutes I find that it has been caused by a different PaddingMode - .NET uses PKCS7 by default, whereas both JavaScript and Java implementations use zeros.
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Hi all,
I have this Error message when i try to run debug on my program "The Machine Debug Manager Service is disabled". Is this caused by the program being too big or is there an option to enable the debug. Please help.
|
|
|
|