|
Hey guys,
I'm quite new to C#. I am using Visual C# 2005 Express which I downloaded from Microsoft.
I have searched for a good 30 minutes, and I couldn't find anything which was helpful.
What I want is, when you press control + u another Form comes up. I have tried this:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.ControlKey && e.KeyCode == Keys.U)
{
username myUsernameDialog = new username();
myUsernameDialog.ShowDialog();
}
}
However, that doesn't work. I really do not know where to go from here.
Thanks in advance,
- Gordon
|
|
|
|
|
hi
This is working. Change the control condition as given below:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control == true)
{
if (e.KeyCode == Keys.U)
{
Form2 a = new Form2();
a.ShowDialog();
}
}
}
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Thank you. Harini
|
|
|
|
|
Hmm...
That doesn't work for some reason :S
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control == true)
{
if (e.KeyCode == Keys.U)
{
MessageBox.Show("Yay!");
username a = new username();
a.ShowDialog();
}
}
}
It compiles/runs fine, but it just doesn't work. Do you know what the problem could be?
Cheers!
p.s. I voted 4/5.
|
|
|
|
|
Hello,
You have to set the "KeyPreview" property to "true" at your Form?
this.KeyPreview=true;
All the best,
Martin
-- modified at 8:00 Wednesday 28th February, 2007
|
|
|
|
|
Thanks mate, that did it! I told you I was new :P
|
|
|
|
|
I have a user control on my asp.net page . This user control has 4 buttons on click of these buttons a new page opens below these user controls. Now after the page is opened and i click anwhere on the page the focus goes to 1st button in user control irrespective of the button i click. Hence when my user hits enter every time the first page opens. I have checked the code and there is no focus set for this in my code. I dont understand why it is happening. I wnt that when the user select a button the focus remains on it even if i click on the page.could some body help me..... I require it.............
-- modified at 5:34 Wednesday 28th February, 2007
|
|
|
|
|
Please don't use all capitals. I lost heart halfway through and stopped reading what you had written because it is just too much to read. Please use mixed casing.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Do you use a postback to open the page below? If you do, then this is the cause of your problem, because ASP.NET doesn't maintain state like this between roundtrips. You could always use JavaScript to set the focus automatically.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi ...
how can create an application that don't show in "task manager-- ctrl+alt+del"
|
|
|
|
|
i don't think so................
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
if you are building any desktop base application then don't write anything in the Text property of Form.
|
|
|
|
|
thank you
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Why would you want to do this? This is the "holy grail" for virus writers.
You should never prevent the user from being able to kill your process because you can't foresee every eventuality, and if your application becomes a memory hog for some reason the user may want to kill it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: Why would you want to do this? This is the "holy grail" for virus writers.
Asked and answered.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
But if he's so inept that he doesn't know how to use Google, we don't really have much to worry about.
|
|
|
|
|
ROTFLMAO
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I want to make a secure erase file tool using c#. I know that there are some rules to be followed when making such a tool(overwriting the file many times,renaming, truncating and than deleting), but i didn't manage to find a document or some site where all this is explained (all i found so far are tons of programs that offer me secure delete solutions, and some well written but old linux document on this matter ... from 96 till now thing have changed a bit ...). Can any of you offer me some recent documentation, or pointers on this ? Thanks.
If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. -Gerald Weinberg
|
|
|
|
|
hey,
i am developing an application, and i need to use something like voice recognition, but this time i want to recognize a sound in a video file, so i thought that i might write the code first to convert video formats to sound formats, and then use speech sdk to recognize that sound.
please could anyone tell me, how can i convert the video formats to sound, through C# code, or if there is another way to recognize that sound in video files.
waiting fro reply
thanx in advance.
--
Cordially,
AmroDigital
|
|
|
|
|
There's an excellent article here on CodeProject by Michael Dunn about intercepting NM_CUSTOMDRAW messages to modify the look of a ListView -- not as involved as OwnerDraw, though, which is nice.
Here's the link: http://www.codeproject.com/listctrl/lvcustomdraw.asp[^]
Unfortunately, the article is not written for C#. I was wondering how to hook into the message stream to intercept and act on NM_CUSTOMDRAW messages in C#. I asked at the article, but Michael does not know.
I've seen the example code in the C# help on using OwnerDraw, but that of course requires handling almost all of the drawing chores. Can we, in C#, hook into the message stream and just do custom draw type stuff like described in Michael's excellent article? If so, how? What event handler do I need? Where do I declare it? Stuff like that. Or do I have to create a ListView derived class and override the WndProc? (which I'd rather not do if I can avoid it)
|
|
|
|
|
Unfortunately, you do have to derive from the class and subclass the window. Subclass the ListView[^], and handle the WM_NOTIFY[^] message. When WM_NOTIFY is received, convert the memory that the lParam parameter points to to an NMHDR[^] instance, and check its code field. If it is set to NM_CUSTOMDRAW , convert the same memory to an NMLVCUSTOMDRAW[^] structure, and work with it as described in Mike's article.
|
|
|
|
|
Wow! One of the best answers I've received here at CodeProject.
Thanks a bunch for the links.
I'll work through it and see what I can do.
Thanks again.
|
|
|
|
|
Hmm. I'm sure this is a totally rookie problem.
I've done my fair share of casting in C++, but I'm pretty new to C#.
How do I cast the lParam to my NMHDR struct in C#?
In my class (which per the link you supplied is derived from NativeWindow), I have NMHDR defined:
private struct NMHDR
{
IntPtr hwndFrom;
IntPtr idFrom;
UInt32 code;
}
Then in the overridden WndProc, I have:
if (m.Msg == WM_NOTIFY)
{
}
And since I am pretty new to C#, I don't know the syntax for this casting.
|
|
|
|
|
OK. I answered my own question.
In case anyone else out there runs into this sort of problem, here's what I found (and it seems to be working):
if (m.Msg == WM_NOTIFY)
{
NMHDR nmHdr = new NMHDR();
nmHdr = (NMHDR)m.GetLParam(typeof(NMHDR));
if (nmHdr.code == NM_CUSTOMDRAW)
{
Debug.WriteLine("Got here.");
}
}
But now I have a different question (there's always something):
Where can I find all the info on the struct.s I need (including, but not necessarily limited to: NMHDR, NMCUSTOMDRAW and NMLVCUSTOMDRAW)? I can find them easily enough by searching MS KB, but is there a file somewhere that I can cut and paste from or just include in my code that already has all of this stuff defined (in C#)? Manually coding all of the structs is kind of a pain.
Thanks.
|
|
|
|
|
You may find what you need at PInvoke.net[^], but they don't have all of the Win32 structures defined.
|
|
|
|
|
Boy, I hope you're not getting irritated with this thread yet because I like learning stuff.
I'm just wondering if you've ever actually attempted what I'm talking about here. Your original response, and the associated links, made it seem as though this might be fairly easy. Unfortunately, the more I learn about it, the harder it seems to be getting.
I was thinking about writing an article discussing OwnerDraw vs CustomDraw to customize the look of a ListView, but the CustomDraw thing seems to be monumental. Just from the standpoint of defining all the structs involved: NMHDR is easy, NMCUSTOMDRAW is fairly straightforward but even that also involves a RECT structure; don't even get me started on NMLVCUSTOMDRAW which involves RECT and COLORREF which itself is fairly complex.
I am persistently running into unhandled exceptions involving read/write to protected memory which I am figuring must be due to not having completely figured all the structs out yet.
I retrieve the LParam using:
nmlvCust = (NMLVCUSTOMDRAW)m.GetLParam(typeof(NMLVCUSTOMDRAW));
and put it back into the LParam using:
Marshal.StructureToPtr(nmlvCust, m.LParam, true);
But somewhere along the chain of messages, at the GetLParam point, I get the access violation.
If you have any suggestions or ideas, please offer. If not, then I figure I'll abandon this for now and perhaps come back to it some other time.
Regardless, thanks for your input -- it has certainly pointed me into areas I've not explored. It's been pretty cool thus far. Thanks.
|
|
|
|