|
hi
i make a win app , iwant to make the action of enter press in keyboard as the action of button OK in my form i dont Know how;)
|
|
|
|
|
Hi,
The Form has an "AcceptButton" property that will do let you this.
Viewing the form in Design mode, look at the properties window. The AcceptButton property will have a list of all the buttons on the form. Pick you one you want.
Or you can set it in code:
<br />
Button MyButton=new Button();<br />
...<br />
Form.AcceptButton=MyButton<br />
According to the Help: "You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ENTER key when they are finished instead of manually clicking the accept button with their mouse."
In a nutshell, when the user hits enter, the Click event on the specified button is fired.
Hope this helps,
Bill
ps: there is a CancelButton property that sets a default button for ESC.
|
|
|
|
|
I've made an implementation of WH_KEYBOARD_LL, however this is only supported in the NT side of windows. I need compatibility with 9x so I'll have to go with WH_KEYBOARD. However, the WH_KEYBOARD isn't system-wide by deafult and has to reside in a seperate library. Would it be a good idea to do this in C# and are there any suggestion and pointers to examples/articles on this?
|
|
|
|
|
There's several articles on hooks here on CodeProject. Just search.
Using a system hook is never a good idea unless you really need to. Using .NET is probably not a good idea either, especially for keyboard and mouse hooks because of the sheer volume of messages posted. If you only need this for an application, take a look at the IMessageFilter interface and the Application.AddMessageFilter method for a much easier, application-specific means.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm developing a utility/accessibility application that needs to monitor the keyboard system wide. If it was a simple application-specific thing it wouldn't be a problem. My problem is getting the hook installed. It just doesn't work.
|
|
|
|
|
Again, there are plenty of articles on CodeProject regarding this topic. You just have to search[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Any articles on saving delta values (only what was changed - much as Visual Source Safe's history) and then reconstructing the two?
As a brief example:
ORGINAL: The cow jumped over the moon.""
NEW: "The horse jumped over the moon."
DELTA would be "horse" - no need to save the entire ORGINAL.
This can become complicated over revisions and I would rather not recreate fire when others already offer matches.
Thanks!
|
|
|
|
|
You can always take a look at CVS and RCS sources and documentation, as they are open source and accomplish the same things.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
In addition, the source code to WinDiff is available.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hi
Another question today, I'm trying to make a web service client in windows form. I add the web reference and I made the instance of the class, but I don't know how I add the argument to the instance???
Thanks
----
hxxbin
|
|
|
|
|
Add a constructor to your web serive with that argument, then in the client you can do it. Its the same as other object oriented you do in your regular coding.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
I'm playing with COM again, and i've managed to obtain an ItemIDList and marshal it to an ItemID structure i've built in C# that contains a pointer to a SHItemID.
However, I'm slightly confused as the ItemIDList does not actualy contain an array, but rather a single instance of SHItemID, which in turn contains a single ItemID value. So for a start, i'm confused as to where the <italic>list element of this is.
However, I do have a pointer from the ItemIDList, and i'm trying to marshal it to a C# version of ItemID.
The problem is, it's having none of it. I'm getting a shell error (no error message, so i assume it's in the shell). I believe this to be caused by the SHItemID being of varying size (the byte array?), and i'm absoloutely clueless as to how to marshal it.
So how do I marshal an unmanaged structure based on the size of it's memory allocation, when all I have is a C# template and an IntPtr to it?
Regards
Cata
|
|
|
|
|
The Catalyst wrote:
So how do I marshal an unmanaged structure based on the size of it's memory allocation, when all I have is a C# template and an IntPtr to it?
Check out Marshal.PtrToStructure[^] method, that's exactly what this does.
- Nick Parker My Blog
|
|
|
|
|
Hi
Any idea or info on how to map a network drive in C#. A code example or a pointer to a web site with info would be appreciated.
Thanks
|
|
|
|
|
Do you want to map the drive...or just access a file on a network share?
|
|
|
|
|
Bill
Thanks for the reply. I need to map the drive as in
which I do in JSCRIPT but have no clue how to use this object in C#.
Thanks
|
|
|
|
|
I am experiencing a very strange problem while trying to set the value of a public field in a class that is being accessed using .NET remoting. Assuming the following definitions:
public enum BuildMethod {
DropBox,
CVS,
}
public class BuildInfo : System.MarshalByRefObject {
/// <remarks>
public BuildMethod Method;
...
}
The problem occurs in my client when I am trying to set the value of the Method field of BuildInfo, i.e.:
xxxx.Method = BuildMethod.DropBox;
There does not appear to be a problem retrieving the value of the Method field, but only when I try to set it.
Exception Details:
System.Runtime.Remoting.RemotingException: The argument type 1 cannot be converted into parameter type Matrix.Definitions.Schema.BuildMethod.
Stack Trace:
[RemotingException: The argument type 1 cannot be converted into parameter type Matrix.Definitions.Schema.BuildMethod.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +264
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +877
System.Object.FieldSetter(String typeName, String fieldName, Object val) +0
Matrix.ProductMgmt.DeliveryMethodEditor.Save_Click(Object sender, EventArgs e) in D:\Matrix\WebApp\Application\ProductMgmt\DeliveryMethodEditor.ascx.cs:116
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +108
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277
I am setting up the channel on the server side like this:
System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider SinkProvider =
new BinaryServerFormatterSinkProvider();
SinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 10782;
this.ServiceChannel = new TcpChannel(props, null, SinkProvider);
ChannelServices.RegisterChannel(this.ServiceChannel);
I am making the object available on the server side using RemotingServices.Marshal().
I would appreciate any help or suggestions that anyone can provide. Thank you,
Clark Laughlin
|
|
|
|
|
Does the remoting server have a reference to the BuildMethod Type? I suspect it either doens't know how to deserialize it (which reminds me, you really should be / have to be using the SerializableAttribute on remotable objects) because it doesn't know the Type, or just doesn't recognize the Type to begin with. The client, on the other hand, would receive an integer representation of the enum and could deserialize that easily, as such is the case since your client can get the field.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You know... I completely overlooked using SerializableAttribute on the enums -- that's probably what the problem is. I'll try it and let you know.
Thank you for the suggestion.
- Clark
|
|
|
|
|
A dummy question,
How I could make a date difference, like VB's DateDiff???. There is a Compare method from DateTime, but don't allow specific the type of data, like years or months.
Anyone know how??
----
hxxbin
|
|
|
|
|
You mean:
DateTime.Now.Subtract(time1);
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
Peforming an operation on two DateTime values (like add and subtract) yield a TimeSpan , as well as using methods like Mazdak mentioned. See the documentation for TimeSpan in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I am not sure this is the right place to post my problem but I think
there are some people out there who can solve my newbie problem. I am
posting my source xml and the code file.
////////////////XML File///////////////
<?xml version="1.0"?>
<!-- a fragment of a book store inventory database -->
<bookstore xmlns:bk="urn:samples">
<book genre="novel" publicationdate="1992" bk:ISBN="1-861001-57-8">
<title>Pride And Prejudice</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
<price>24.95</price>
</book>
<book genre="novel" publicationdate="1992" bk:ISBN="1-861002-30-1">
<title>The Handmaid's Tale</title>
<author>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
</author>
<price>29.95</price>
</book>
<book genre="novel" publicationdate="1991" bk:ISBN="1-861001-57-6">
<title>Emma</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
<price>19.95</price>
</book>
<book genre="novel" publicationdate="1982" bk:ISBN="1-861001-45-3">
<title>Sense and Sensibility</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
<price>19.95</price>
</book>
</bookstore>
////////////////Code File/////////////////
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class Sample
{
public static void Main()
{
XPathDocument doc = new XPathDocument("booksort2.xml");
XPathNavigator nav = doc.CreateNavigator();
//Select all books by Jane Austen.
XPathExpression expr;
expr = nav.Compile("descendant::book[@publicationdate='1992']");
//Sort the selected books by title.
expr.AddSort("@ISBN", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text);
//Display the selection.
XPathNodeIterator iterator = nav.Select(expr);
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
nav2.MoveToFirstChild();
Console.WriteLine("Book ISBN: {0}", nav2.Value);
}
}
}
/*
I want an output like this:
//////////////////////////////////
Book ISBN: 1-861001-57-8
Book ISBN: 1-861002-30-1
//////////////////////////////////
But I get this???
//////////////////////////////////
Book ISBN: Pride And Prejudice
Book ISBN: The Handmaid's Tale
//////////////////////////////////
*/
Any help will be appreciated, Thanx
|
|
|
|
|
I'm not an expert on the XmlNavigator class (I usually just use SelectNodes and get a collection of XmlNodes), but I think I see your problem.
You're finding a bunch of book nodes, and then you're moving to the first child, expecting to find the ISBN. The first child (child node) of book is the title node. What you want is an attribute, and not a child (isbn is an attribute and not a child node).
Take a look at XmlNavigator.GetAttribute. I think that will allow you to get the ISBN.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Thank you it is because of my language I think I didn't know what the meaning of attribute... I changed the loop with the one below and it worked Thanx anyway...
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
nav2.MoveToAttribute("ISBN", "urn:samples" );
Console.WriteLine("Book ISBN: {0}", nav2.Value);
}
|
|
|
|