Direct sound/Form/RichEdit/Real time

I use direct sound to get blocks of audio samples in real time. There is an
event at each new block.

My code is called by clicking a button in a form: it initializes direct
sound then waits for messages and events in a loop with a call to
MsgWaitForMultipleObjects.

All works well but:
when I'm maintaining the mouse button down on a RichEdit control or its
barr, or on some other controls, or when a save/openDialog box is opened,
the code in the loop is no more executed.
It's the same thing when I run another thread: it stops. So the problem
seems to be general.

How to handle the loop in real time for waiting messages and events and how
to run a thread, without being interrupted by the mouse button down or by
opening dialog boxes in the main form?

Thanks in advance for help.