Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPhysical menu size ??? Pin
Christian Graus9-Jan-02 16:11
protectorChristian Graus9-Jan-02 16:11 
AnswerRe: Physical menu size ??? Pin
Derek Waters9-Jan-02 19:51
Derek Waters9-Jan-02 19:51 
GeneralLoading ActiveX from another ActiveX Pin
mad05039-Jan-02 16:00
mad05039-Jan-02 16:00 
QuestionDisable CButton while function executes? Pin
9-Jan-02 10:40
suss9-Jan-02 10:40 
AnswerRe: Disable CButton while function executes? Pin
Alvaro Mendez9-Jan-02 12:24
Alvaro Mendez9-Jan-02 12:24 
AnswerRe: Disable CButton while function executes? Pin
Eugene Pustovoyt9-Jan-02 19:59
Eugene Pustovoyt9-Jan-02 19:59 
AnswerRe: Disable CButton while function executes? Pin
Nish Nishant9-Jan-02 22:08
sitebuilderNish Nishant9-Jan-02 22:08 
GeneralRe: Disable CButton while function executes? Pin
10-Jan-02 4:40
suss10-Jan-02 4:40 
Thanks for all your ideas...

I'm using the mciSendCommand fuction with the MCI_WAIT flag so that it doesn't return until the play is done. This seems to work because the button grays out while its playing and then is re-enabled after the play stops. Nevertheless, I can still click again on the grayed-out button while the .wav is playing and it will play again after it finishes.

I tried to insert the ::PeekMessage code with no results.

I'll look into the sndPlaySound function also, but maybe I can solve this from another approach. I copied my play wave function out of the MSDN help files for MCI, but didn't know how to handle the notify message in my dialog. Maybe someone could help me with this and it would solve the problem? Here's my complete code:

void CWaveTestDlg::OnPlay()
{
if (isPlaying) return;
isPlaying = TRUE;
CWaitCursor wc;
UpdateData(TRUE);
if (m_wave.GetLength() <= 0)
{
AfxMessageBox("Please enter a wave file name.");
return;
}
CButton* pPlayButton;
pPlayButton = (CButton*) GetDlgItem(IDC_PLAY);
ASSERT(pPlayButton != NULL);
pPlayButton->EnableWindow(FALSE);
LPTSTR pStr = m_wave.GetBuffer(0);
CString msg;
MCIERROR mciErr;
if (mciErr = playWAVEFile((HWND) this, pStr))
{
char errStr[128];
LPTSTR pErrStr = errStr;
if (mciGetErrorString(mciErr, pErrStr, 128))
msg.Format("Unknown Error playing Wave File");
else
msg.Format("Error playing wave file : %s", pErrStr);
AfxMessageBox(msg);
}
isPlaying = FALSE;
pPlayButton->EnableWindow(TRUE);
pPlayButton->SetFocus();
}

DWORD CWaveTestDlg::playWAVEFile(HWND hWndNotify, LPSTR lpszWAVEFileName)
{
UINT wDeviceID;
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
mciOpenParms.lpstrDeviceType = "waveaudio";
mciOpenParms.lpstrElementName = lpszWAVEFileName;
if (dwReturn = mciSendCommand(0, MCI_OPEN,
MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
(DWORD)(LPVOID) &mciOpenParms))
{
return (dwReturn);
}
wDeviceID = mciOpenParms.wDeviceID;
// Begin playback. The window procedure function for the parent
// window will be notified with an MM_MCINOTIFY message when
// playback is complete. At this time, the window procedure closes
// the device.
mciPlayParms.dwCallback = (DWORD) hWndNotify;
if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_WAIT,
(DWORD)(LPVOID) &mciPlayParms))
{
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return (dwReturn);
}
//I inserted this next line so that the device is
//closed from within the function...cause I didn't know how
//to handle the callback notification message.
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return (0L);
}

Thanks!
GeneralRe: Disable CButton while function executes? Pin
James R. Twine10-Jan-02 7:26
James R. Twine10-Jan-02 7:26 
GeneralRe: Handle MM_MCINOTIFY notify message Pin
11-Jan-02 7:30
suss11-Jan-02 7:30 
GeneralRe: Handle MM_MCINOTIFY notify message Pin
James R. Twine11-Jan-02 19:00
James R. Twine11-Jan-02 19:00 
GeneralFinding and the keep go'n! Pin
Rickard Andersson209-Jan-02 10:38
Rickard Andersson209-Jan-02 10:38 
GeneralRe: Finding and the keep go'n! Pin
Christian Graus9-Jan-02 10:50
protectorChristian Graus9-Jan-02 10:50 
GeneralRe: Finding and the keep go'n! Pin
Alvaro Mendez9-Jan-02 12:42
Alvaro Mendez9-Jan-02 12:42 
GeneralRe: Finding and the keep go'n! Pin
Christian Graus9-Jan-02 13:21
protectorChristian Graus9-Jan-02 13:21 
GeneralRe: Finding and the keep go'n! Pin
Alvaro Mendez9-Jan-02 16:11
Alvaro Mendez9-Jan-02 16:11 
GeneralRe: Finding and the keep go'n! Pin
Christian Graus9-Jan-02 16:52
protectorChristian Graus9-Jan-02 16:52 
GeneralRe: Finding and the keep go'n! Pin
Alvaro Mendez9-Jan-02 17:22
Alvaro Mendez9-Jan-02 17:22 
GeneralC++ Win32 API: Pictures on buttons... Pin
ParaSwarm9-Jan-02 10:33
ParaSwarm9-Jan-02 10:33 
GeneralRe: C++ Win32 API: Pictures on buttons... Pin
Christian Graus9-Jan-02 10:36
protectorChristian Graus9-Jan-02 10:36 
QuestionPrintInsideRect for CScrollView? Pin
Joe Dean9-Jan-02 9:16
Joe Dean9-Jan-02 9:16 
AnswerRe: PrintInsideRect for CScrollView? Pin
Ernest Laurentin9-Jan-02 10:19
Ernest Laurentin9-Jan-02 10:19 
QuestionIs Visual C++ running? Pin
Gavin Greig9-Jan-02 9:00
Gavin Greig9-Jan-02 9:00 
AnswerRe: Is Visual C++ running? Pin
Carlos Antollini9-Jan-02 9:47
Carlos Antollini9-Jan-02 9:47 
AnswerRe: Is Visual C++ running? Pin
Carlos Antollini9-Jan-02 9:50
Carlos Antollini9-Jan-02 9:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.