Well, sorry I frustrated you...
re: your "Second..."
Getting back to my original PlaySound problem, I am trying to play a sound, start a timer in a separate thread, paint a window, return control to the user, and when the timer thread runs out send a message to the UI thread to repeat the process with the switch variable incremented, and repeat the process for a second sound, etc, as outlined below:
In the button WndProc:
case WM_LBUTTONUP:
DWORD Thread = GetCurrentThreadID(hWnd, NULL);
switch(step) { // a global int, set to 0 at startup
case 0:
PlaySound(_T("Sound_0.wav"

, 0, SND_ASYNC);
_beginthread(MyProc, 0, &Thread);
InvalidateRect(GetParent(hWnd), &rt, TRUE);
step++;
case 1:
PlaySound(_T("Sound_1.wav"

, 0, SND_ASYNC);
_beginthread(MyProc, 0, &Thread);
InvalidateRect(GetParent(hWnd), &rt, TRUE);
step++;
case 2:
PlaySound(_T("Sound_2.wav"

, 0, SND_ASYNC);
_beginthread(MyProc, 0, &Thread);
InvalidateRect(GetParent(hWnd), &rt, TRUE);
step++;
default:
break;
}
if(step>2)
step=0;
return 0; // end of the handling of the WM_LBUTTONUP message
and MyProc() does:
void MyProc(PVOID, pThread) {
DWORD * pThr;
pThr = (DWORD*) pThread;
switch(step) {
case 0:
Sleep(5000);
PostMessage(*pThr, WM_LBUTTONUP, 0,0);
break; // 'step' will == 1 on return
case 1:
Sleep(5000);
PostMessage(*pThr, WM_LBUTTONUP, 0,0);
break; // 'step' will == 2 on return
case 2:
Sleep(5000);
PostMessage(*pThr, WM_LBUTTONUP, 0,0);
break; // 'step' will == 3 on return
default:
break;
}
_endthread;
}
Okay, so I thought that when I posted a message to the thread with PostthreadMessage(), the message was put in the queue just like with SendMessage() in the UI thread, but I guess that is not the case.
Where is the myThreadMsgHandler() function call placed?
Thanks,
Steve (who is not the experienced Multithreaded-Man!)