我阅读了一些文档,看起来“status”命令是解决方案,但我不明白如何使用它。
以下是“case IDC_Play:”
的代码if ((SendDlgItemMessage(hDlg, IDC_CHECK1, BM_GETSTATE, NULL, NULL)) == BST_CHECKED)
{//here goes the code for play only one song}
else {
int cuenta = SendDlgItemMessage(hDlg, IDC_LIST1, LB_GETCOUNT, NULL, NULL);
int indice = 0;
while (indice != cuenta) {
char auxi[10] = "";
UINT index = SendDlgItemMessage(hDlg, IDC_LIST1, LB_GETCURSEL, 0);
SendDlgItemMessage(hDlg, IDC_LIST1, LB_GETTEXT, index, (LPARAM)auxi);
if (strcmp(auxi, "") == 0) {
MessageBox(NULL, "No se selecciono cancion", "ERROR", MB_ICONERROR);
}
else {
char Cnum[10];
aux = inicio;
aux = aux->sig;
do {
_itoa_s(aux->folio, Cnum, 10);
if (strcmp(auxi, Cnum) == 0) {
strcpy_s(szFileName, aux->mptres);
bmp1 = (HBITMAP)SendDlgItemMessage(hDlg, IDC_Imagen1, STM_GETIMAGE, IMAGE_BITMAP, 0);
bmp2 = (HBITMAP)LoadImage(NULL, aux->imagen, IMAGE_BITMAP, 140, 120, LR_LOADFROMFILE);
SendDlgItemMessage(hDlg, IDC_Imagen1, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp2);
}
else {
aux = aux->sig;
}
} while (strcmp(auxi, Cnum) == -1 || strcmp(auxi, Cnum) == 1);
ShowWindow(GetDlgItem(hDlg, IDC_Play1), SW_HIDE);
ShowWindow(GetDlgItem(hDlg, IDC_Pause1), SW_SHOW);
char comillas[MAX_PATH] = "\"";
char comillas2[MAX_PATH] = "\"";
strcat_s(comillas, szFileName);
strcat_s(comillas, comillas2);
char musica[MAX_PATH] = "open ";
strcat_s(musica, comillas);
strcat_s(musica, " type mpegvideo");
mciSendString(musica, NULL, 0, 0);
char musica1[MAX_PATH] = "play ";
char esperar[MAX_PATH] = " wait";
strcat_s(musica1, comillas);
strcat_s(musica1, esperar);
mciSendString(musica1, NULL, 0, 0);
char parar[MAX_PATH] = "stop ";
strcat_s(parar, comillas);
mciSendString(parar, NULL, 0, 0);
char cerrar[MAX_PATH] = "close ";
strcat_s(cerrar, comillas);
mciSendString(cerrar, NULL, 0, 0);
index++;
SendDlgItemMessage(hDlg, IDC_LIST1, LB_SETCURSEL, index, NULL);
SendDlgItemMessage(hDlg, IDC_LIST2, LB_SETCURSEL, index, NULL);
SendDlgItemMessage(hDlg, IDC_LIST3, LB_SETCURSEL, index, NULL);
SendDlgItemMessage(hDlg, IDC_LIST4, LB_SETCURSEL, index, NULL);
SendDlgItemMessage(hDlg, IDC_LIST5, LB_SETCURSEL, index, NULL);
indice = index;
} //else
} //while
}//else
答案 0 :(得分:0)
也许你应该使用MM_MCINOTIFY
标志和回调来避免冻结整个应用程序的阻塞调用?
请参阅CodeProject使用回调和标记的示例:http://www.codeproject.com/Articles/17279/Using-mciSendString-to-play-media-files