Click to See Complete Forum and Search --> : [RESOLVED] KeyEvents


David19
August 20th, 2009, 06:21 PM
Hi, i'm implementing some shortcut keys for a c# windows application, now whenever i press a shortcut key i hear background windows alert (beep) sounds, how can i avoid these beeps?

rliq
August 20th, 2009, 08:17 PM
Is your application already doiong something (busy) when you press the shortcut key?

Does the code you associate with the shortcut key (ie the Event Handler) get executed?

David19
August 20th, 2009, 09:05 PM
i'm making a windows.forms.form diag to appear whenever i press the shortcut key. for the first it works fine but when i press the key for the second time, the form diag appears with beep noise. when i use the mouse controls (context menu) to work with it then all everything goes well.

rliq
August 20th, 2009, 09:33 PM
I just created a windows forms app. Created a context menu with one item on it "ShowDlg ctrl+s". Assigned the context menu to the form. Added a handler to the menu item to do a MessageBox.Show("Hello").

Right click on the form with the mouse choose the menu option, the MessageBox appears with a beep.

Close the MessageBox. Type ctrl+s and the message box appears with a beep.

Seems both, in my case, beep. Not sure if this is because I am using the standard MessageBox and not my own dialog...

rliq
August 20th, 2009, 09:37 PM
Changed my app to display another windows form. This new form contains one button that is associated with the CancelButton property of the form.

private void showDlgToolStripMenuItem_Click(object sender, EventArgs e)
{
Dlg d = new Dlg(); // Dlg is the name of the class of my new form
d.ShowDialog(); // not d.Show() as this prevent the button from closing the form
}

Now it works perfectly in both cases, without sound. So it seems as though the standard message box makes a noise.

Can you post your menu handler code....

David19
August 21st, 2009, 12:00 AM
I've just figured that i was using the keyDown event on a docked ListView Control which needs to be linked with the main form. so when i was pressing a key it goes looking for that character in the list and returns a beep if it wasn't present in list.