Click here to Skip to main content
13,056,229 members (108,533 online)
Rate this:
Please Sign up or sign in to vote.
For ValidationError, usually we use MessageBeep function.
But unfortunately MessageBeep is asynchronous (After queuing the sound, the MessageBeep function returns control to the calling function and plays the sound asynchronously.).

Where Beep function is synchronous (Generates simple tones on the speaker. The function is synchronous; it performs an alertable wait and does not return control to its caller until the sound finishes.).

If you make a CEdit control validator for numerical chars with a MessageBeep function for ValidationError, and when the user still hitting the wrong key chars, so the sound won't play.
Beep is the preferred function in this situation.

Question: What is the equivalent Beep function Parameters (DWORD dwFreq and DWORD dwDuration) of this code:
MessageBeep(0xFFFFFFFF); // A simple beep. If the sound card is not available, the sound is generated using the speaker.
Posted 7-Jan-12 4:35am
Updated 7-Jan-12 4:49am
Mehdi Gholam339.8K
SAKryukov 7-Jan-12 15:26pm
What's wrong with asynchronous beep?
tomay3000 7-Jan-12 18:20pm
when the user still hitting the wrong key chars, so the sound won't play.
Albert Holguin 7-Jan-12 21:23pm
Why don't you just listen to both and approximate the Beep() parameters by ear? If you get them close enough I'm sure a user wouldn't be able to distinguish them anyway. The whole point of beep is just to alert of an issue anyway so as long as it's clearly audible, that should be the important point.
tomay3000 8-Jan-12 4:22am
By ear, you're saying: That's difficult (The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). ).
I am sure there is a way to reveal the secret of Microsoft (May be debugging MessageBeep(0xFFFFFFFF); function), I don't know!

I have debugged an MFC example with an edit control with Number Flag Checked, and make a break point on MessageBeep, so when I Enter some non numerical char keys, a call to the MessageBeep function is never invoked, but I hear a beep!!!

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


From the trail I can't directly figure out if you're just not happy with the frequency of synchronous call and/or you can't get the async to work. If the latter is the case I suggest that you post the non working code.

Anyway what may be of interest for you is to check out a third option: PlaySound[^]

This may just work for you.

Cheers, AT
tomay3000 12-Jan-12 14:59pm
Awesome & very helpful
Thanks ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170728.5 | Last Updated 12 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100