Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 C++ C MFC validation
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 5:35am
tomay30001.2K
Edited 7-Jan-12 5:49am
Mehdi Gholam249.7K
v4
Comments
SAKryukov at 7-Jan-12 15:26pm
   
What's wrong with asynchronous beep?
--SA
tomay3000 at 7-Jan-12 18:20pm
   
when the user still hitting the wrong key chars, so the sound won't play.
Albert Holguin at 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 at 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
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
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
  Permalink  
Comments
tomay3000 at 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
0 OriginalGriff 584
1 Maciej Los 275
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 12 Jan 2012
Copyright © CodeProject, 1999-2014
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