|
What about This. It hook the keyboard, and mouse event as well.
|
|
|
|
|
My application allow user press Ctrl + S to save changes to document.
But how can I get this event?
|
|
|
|
|
You can subscribe to your form's KeyDown event. Then using the KeyEventArgs parameter to parse out what key was pressed.
If for some reason this isn't enough information for you, just let me know.
/\ |_ E X E GG
|
|
|
|
|
You can find a lot of example, and complete code/components in Here
|
|
|
|
|
Use the Shortcut property of the menu item in your main menu. That way it'll show up there too.
If you have a main menu, that is.
|
|
|
|
|
I think we have to check if the S is press while Ctrl is pressing.
It confuse me!
|
|
|
|
|
There's a setting in the main menu object properties that lets you choose from like a hundred different key combinations, Ctrl+S is one of them.
Otherwise, you can set a KeyDown event, and do this:
<br />
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
<br />
if(e.Modifiers == Keys.Control && e.KeyCode == Keys.S)<br />
{<br />
}<br />
}<br />
<br />
|
|
|
|
|
reinux, thank you for your helping.
I think that is what I need.
|
|
|
|
|
I'm trying to implement a module that transmits custom objects through net(between tcp clients), I'm familiar with such thing in Java(ObjectInputStream and ObjectOutputStream). My question is: is there are something like that in C# and how to use it?
Thanx in advance, Evgeny
evgenyus
|
|
|
|
|
Yes there is. Look for the System.Runtime.Serialization namespace. There you'll find a BinaryFormatter and a SoapFormatter class for serializing the objects. You can then use the NetworkStream to transfer them over. Something like
using System.Runtime.Serialization.Formatters;
void SendObject(object o, Stream s)
{
new BinaryFormatter.Serialize(o, s);
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I have a .gif I downloaded off the net as an Image type in my code. How can I take that and have it displayed as the icon for my NotifyIcon.Icon ?
/\ |_ E X E GG
|
|
|
|
|
Bitmap b = new Bitmap("filename.gif");
b.Save("d:\newname.ico",System.Drawing.Imaging.ImageFormat.Icon);
Icon c = new Icon("d:\newname.ico");
this.notifyIcon1.Icon = c;
|
|
|
|
|
Have you actually tried this, because I think I did something exactly like that and it didn't work.
/\ |_ E X E GG
|
|
|
|
|
Why? what was the problem? Maybe try convert that .gif to .ico with some application?
David
|
|
|
|
|
Argument Exception, "Argument 'picture' must be a picture that can be used as a Icon."
/\ |_ E X E GG
|
|
|
|
|
|
If I use the code LongHC provided, it dosn't work at runtime. Then if I try to make NotifyIcon.Icon the icon that LongHc's code created I get the same error except in a messagebox in the designer.
---------------------------
Microsoft Visual Studio
---------------------------
Argument 'picture' must be a picture that can be used as a Icon.
---------------------------
OK
---------------------------
/\ |_ E X E GG
|
|
|
|
|
Yeah, I get an ArgumentException, "Argument 'picture' must be a picture that can be used as a Icon."
/\ |_ E X E GG
|
|
|
|
|
Sph, forget CodeProject, I did it myself.
WebRequest requestIcon = WebRequest.Create("http://www.met-office.gov.uk/images/w1x15.gif");
WebResponse responseIcon = requestIcon.GetResponse();
Image image = Image.FromStream(responseIcon.GetResponseStream());
responseIcon.Close();
Bitmap b = new Bitmap(image, 16, 16);
notifyIcon1.Icon = Icon.FromHandle(b.GetHicon());
/\ |_ E X E GG
|
|
|
|
|
How can I add a type Image or any picture/image to a ListView at runtime without using an ImageList .
For example, I have an image type Image , I just want to add it to a row in my ListView .
So far the only way I've been able to do this is by first making a SmallImageList and putting my Image in it, then associating that ImageList with my ListBox , and then setting the ImageIndex to 0 for my Image .
That's alot of work. Can I simply just add an image?
/\ |_ E X E GG
|
|
|
|
|
No, you can't. Even each item in a ListView can have it's own ImageList.
But in no case can you just "add an Image" and move on.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ok, thanks.
/\ |_ E X E GG
|
|
|
|
|
I have a form that I have show up when a lengthy process (doing a search through files) is ongoing basically as a status window. The trouble is that controls don't paint properly.
Below is a link to a picture of what it kind of looks like (the left side of the form didn't capture well for some reason although it actually correctly displays):
Here[^]
How can I resolve this?
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
Without knowing anything about how your searching for files, your threading setup, form and code details, ... There's nothing we can do to help.
All we know is, your searching for files and trying to display a progress form. Since there are about a dozen different ways of doing this, it's a bit hard to help you with a description of "My code doesn't work, help!"
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
As Dave said its hard to help you without more details. But my guess would be you do you operation in the same thread as the GUI. If you do this the GUI doesn't get the time to repaint itself. If this is the case you have two options:
1. Make your search in a seperate thread (better).
2. Try to call System.Windows.Forms.Application.DoEvents() regulary - but not too often (faster to implement but not very clean and probably slower).
|
|
|
|