DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Beep on Events (MSVC++ 2005) (http://www.daniweb.com/forums/thread166853.html)

chococrack Jan 7th, 2009 4:07 pm
Beep on Events (MSVC++ 2005)
 
I am having trouble finding out info regarding how to stop my application from "Beeping" every time I change focus with the "ENTER" key.

For the sake of clarity here is the specific action and code which produces a sound (which I want to eliminate):

I am simply trying to change focus from one textBox to the other, when for instance a Last Name is entered, the user presses ENTER and it switches to the next textbox.



private: System::Void textLast_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) {
               
                        if (e->KeyValue == (char)13)
                        {
                                textFirst->Focus();
                               
                        }
}

The code works, but every textbox that I hit "Enter" on, I get an Alert or BEEP that I want to go away.

MatEpp Jan 7th, 2009 6:34 pm
Re: Beep on Events (MSVC++ 2005)
 
Well if I remember correctly the Console.Beep is part of the system namespace. So you might want to research the system namespace, which could be causing the BEEP that you are hearing.

chococrack Jan 8th, 2009 12:54 pm
Re: Beep on Events (MSVC++ 2005)
 
It's not so much a beep as it is an event sound. I'm writing this for a person who will be running this on his own machine, so disabling the windows sounds is not an option. It sounds as though it is playing the alert sound (similar to a popup "OK" box Alert). I'm not too sure where to go from here, as the textboxes work as they should but produce a sound I do not want. :/

MatEpp Jan 9th, 2009 1:26 pm
Re: Beep on Events (MSVC++ 2005)
 
Okay I'm out of my league hear, but this sounds similar to your problem.

http://social.msdn.microsoft.com/For...-fe4203c0ab81/

chococrack Jan 11th, 2009 12:51 am
Re: Beep on Events (MSVC++ 2005)
 
Referencing the link: http://www.vbforums.com/showthread.php?t=527469

MatEpp's comment lead me to a working solution.

the actual code which eliminates the sound for me is as follows:

if (e->KeyValue == (char)13)
{
    e->SuppressKeyPress = true;  // the magic
    textBox2->Focus();
}

Thanks for the help!


All times are GMT -4. The time now is 11:32 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC