Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing Mouse/Keyboard Buffer when using Playsound.

Status
Not open for further replies.

KAGEY

Programmer
Apr 30, 2003
2
0
0
GB
If I am using playsound, using the SYNC flag, is there a way of clearing the mouse/keyboard buffer, to stop keys/clicks being queued up?
 
I don't know for sure but I am unaware of any API to block the message queue. So let's look at other ways of accomplishing your goal and if someone else shows how to block the message queue you can RF my post [lol]

You could use proprietary messages to mark the start/stop of the sound and eat all the messages that arrive in your windows procedure in-between. If your using MFC you would override CWnd::preTranslateMessage()
Code:
SendMessage(m_hWnd, WM_USER_STARTSOUND, 0, 0L);
PlaySound(...);
SendMessage(m_hWnd, WM_USER_ENDSOUND, 0, 0L);

Don’t forget to change to the hourglass (busy) cursor during this time.

Another technique would be to use a worker thread and synchronization but that seems overkill.


-pete
[sub]I just can't seem to get back my IntelliSense[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top