|
The Win32Native class is internal . This means that those methods and members are only visible to that particular assembly, not to your code.
- Nick Parker My Blog | My Articles
|
|
|
|
|
This error appears when i decrypt the message that is read from a file. The message in this file is encrypted. Before encrypting the message, this message is Xml data that read from a xml file.
What is the meaning of this error ? Thanks for help
Mscorlib (in Mscorlib.dll)
at System.Security.Cryptography.CryptoAPITransform._DecryptData(IntPtr hKey, Byte[] rgb, Int32 ib, Int32 cb, Boolean fDone)
at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
at System.Security.Cryptography.CryptoStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at WindowsApplication3.Form1.button10_Click(Object sender, EventArgs e)
|
|
|
|
|
This message is not complete part of your exception. It only say where does exception happen but you didn't send error message and your code so we can help yu more.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
Actually, there was no exception being thrown.
If you have seen the code ... the try-catch is something that i insert to see what thing is happening ...
This is because ... the program was hanged in the do loop ...
I don't know how to express ... if you have tried the code, you will know what is happening...
Things made me mad ...
Anyway, thanks for your reply ...
i still look forward you can help me to solve this problem ....
|
|
|
|
|
how to scan a barcode and input it to my c# code
how to know information about all this senario?
|
|
|
|
|
Reading barcodes from documents that have been printed with some kind of symbology is a kind of micro-specialization. There are several different kinds of symbols used (UPC, EAN, Interleaved 2 of 5, Code 39, etc.) in which barcodes are produced by printing on laser printers, barcode label printers, dot matrix printers, etc... and then you have readers (wands, scanners, etc.) that are either serial or keyboard wedge readers. The latter -- keyboard wedge -- are easier to use, and often plug and play. A decent reader will cost between US$100 and US$200 and should be programmable to read different symbols, look for check digits, etc. Once you have a reader, you can get the result into a text box just as though someone had typed the information using a keyboard.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
I'm trying to build a 2-player game that uses the keyboard to control the game elements. I'd like certain keys to control player 1 and others to control player 2. I was thinking about doing this by having each player's game piece contain a controller object that is used to capture key events and then call back to the game piece to do things like set direction. The controller would implement IMessageFilter and the game piece would create it like: Application.AddMessageFilter( new Ctrl( this )). Wondering if it's possible to add multiple message filters like this.
|
|
|
|
|
I don't really think that you would need two message filters to handle this process, one should do the trick. The key that is press gets packed into the WParam of the Message so once you evaluate what was hit you can simply dispatch control to the appropriate method.
private const int WM_KEYDOWN = 0x0100;
public bool PreFilterMessage(ref Message m)
{
if(m.Msg == WM_KEYDOWN)
{
char c = (char)m.WParam;
if(c == 'A')
MessageBox.Show("A was hit");
}
return false;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Well, what I'm trying to do is have each controller be associated with a specific game piece. That way I don't have to keep track of what game pieces were created or hard code specific references. If I want to create 2 players, I can, but if I later decide to create 7 players, I don't have to change much code.
|
|
|
|
|
Yes it's possible, which is why the related methods are called AddMessageFilter and RemoveMessageFilter . There is a reason to keep a consistent naming convention, and Microsoft has done that with 90% of their code.
You also could've just thrown together a quick example. Throwing together samples is a staple of development.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry for the delayed response... been busy with school.
I had written an example, but it did not work. I have two instances of a class that each create their own controller (which derives from IMessageFilter) and passes it to Application.AddMessageFilter. However, only one of the controllers' PreFilterMessage functions is capturing input. The second one is never called. This is why I was wondering if it was possible to have two since it only seems to be working with one.
|
|
|
|
|
Works fine for me. Internally, when you add an IMessageFilter implementation it gets added to an ArrayList , so it doesn't even matter if you add the same instance more than once. If you return true from your PreFilterMessage method (not "function", objects have "methods", btw), then the message does not get dispatched. I looked quickly and didn't find whether or not it is sent to remaining message filters or not right away. More than likely it is.
If you want, verify that things are working with my little test app which adds three message filters, 2 in the static entry point and another in one of the constructors, which makes 2 filters added using the same instance of a class:
using System;
using System.Windows.Forms;
public class Test : Form, IMessageFilter
{
static void Main()
{
Test t = new Test();
Application.AddMessageFilter(t);
Application.AddMessageFilter(new MessageFilter());
Application.Run(t);
}
public Test()
{
Application.AddMessageFilter(this);
Text = "Test";
}
public bool PreFilterMessage(ref Message m)
{
Print(this, m);
return false;
}
internal static void Print(object obj, Message m)
{
Console.WriteLine("[{0}] 0x{1:x2} -> 0x{2:x2}",
obj.GetType().Name, m.Msg, m.HWnd);
}
}
public class MessageFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
Test.Print(this, m);
return false;
}
} Like me, you should get three lines with each message sent to the application pump, like so:
[Test] Message.Msg -> Message.HWnd
[MessageFilter] Message.Msg -> Message.HWnd
[Test] Message.Msg -> Message.HWnd
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yep, found the problem within seconds of reading your email. I was returning true and the message was not making it any further. Duh. Thanks so much for the help, this is all a lot clearer to me now.
|
|
|
|
|
Hi all,
I have a datagrid populated from an XML file like the following:
<?xml version="1.0" standalone="yes"?>
<pairs xmlns="http://tempuri.org/Data.xsd">
<pair>
<x>3</x>
<y>10</y>
</pair>
<pair>
<x>4</x>
<y>17</y>
</pair>
...
</pairs>
and would like to convert this to a string of the values like this:
3 10 4 17 ...
(to create input for an old C++ app, just the values in one long string - nothing but numbers and spaces)
I hoped this would be fairly straightforward, but I haven't found how to do it.
(I could transform the XML file if necessary)
Any help much appreciated.
---
J
|
|
|
|
|
With the below XML, I wrote this quick method to return a string value as you have requested.
<?xml version="1.0" standalone="yes"?>
<pairs>
<pair>
<x>3</x>
<y>10</y>
</pair>
<pair>
<x>4</x>
<y>17</y>
</pair>
</pairs>
private string GetInput()
{
XmlDocument doc = new XmlDocument();
StringBuilder sb = new StringBuilder();
XmlNode buffer = null;
doc.Load("../../data.xml");
XmlNodeList nodes = doc.SelectNodes("//pairs/pair");
if(nodes != null)
{
foreach(XmlNode node in nodes)
{
buffer = node.SelectSingleNode("x");
if(buffer != null)
sb.Append(buffer.InnerXml + " ");
buffer = node.SelectSingleNode("y");
if(buffer != null)
sb.Append(buffer.InnerXml + " ");
}
}
return(sb.ToString());
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
excellent, thank you.
hadn't come across string builder before, am sure it will be useful.
---
|
|
|
|
|
It's very useful - especially when formatting unknown lengths of strings. The String class is immutable - any changes to it force another string to be created and the chars within the original string to be copied to the new string merged with the changes you've made. Do this several hundred times and you're app is slow. The StringBuilder is a mutable string and eliminates these problems and should be used when appending strings like Nick pointed out. The StringBuilder is also used internally in many methods like String.Format .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I get dates in the following format:
Mar-07 13:45
How can I feed this to a ConvertTo.DateTime expression without getting an exception?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Tough luck. I think you need to write your own function to read it and convert it to ISO format.
Check if the format is always mmm-dd hh:nn. If it is, it will be simpler for you to write the function.
I might be wrong though, so if anyone knows about this, feel free to answer.
Edbert P.
Sydney, Australia.
|
|
|
|
|
Yes in fact, it is always in this format.
How should I write this function?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
I've checked that in your case you only need to add the year value to the string.
Here's what I would do:
string dateValue = "Mar-07 13:45";
string[] dateParts = dateValue.Split(' ');
dateValue = String.Concat(dateParts[0], "-", DateTime.Now.Year, " ", dateParts[1]);
You can use the final string as input for any DateTime functions.
Edbert P.
Sydney, Australia.
|
|
|
|
|
A word of warning when reading December's data in January - it may have wrong year!
Remember to add logic something like pseudocode:
if(Month(data) > Month(Now))
DataYear -= 1;
Regards
Brewman
|
|
|
|
|
Is it possible to add events to each cell of a Datagrid? For eg., I have a datagrid where I want to trigger something when the user navigates to row 3, cell 2. How do I do that?
Thanks
Al
|
|
|
|
|
private void grid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid dg = (DataGrid)sender;
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dg.HitTest(pt);
if(hti.Type == DataGrid.HitTestType.Cell)
{
if(hti.Row ==2 && hti.Column==3)
{
//do something
}
}
}
You can get HitTestInfo, and check if Hit Type is CELL (not row header/column header), and then get the corresponding ROW & COLUMN information.
Hope this help
Ruchi
|
|
|
|
|
Hi Ruchi,
Thanks for the info! I was thinking more in terms of events like "When cursor leaves cell", "when cursor enters cell" etc. Do you know if that is possible with C# Datagrids?
Thanks
Al
|
|
|
|