用vc++开发一个音乐播放器
voidMain_OnCommand(HWNDhwnd,intid,HWNDhwndCtl,UINTcodeNotify){switch(id){caseIDC_OK:{...
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_OK:
{
OPENFILENAME ofn;
char szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = TEXT('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.TXT\0mp3\0*.mp3\0word\0*.doc\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;//自学能力、探索能力、猜测能力
ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
TCHAR shortPath[MAX_PATH];
GetShortPathName(szFile,shortPath,sizeof(shortPath));
TCHAR cmd[MAX_PATH+10];
wsprintf(cmd,"play %s",shortPath);
//MessageBox(hwnd,shortPath,shortPath,MB_OK);
mciSendString(cmd,"",0,NULL);
SetDlgItemText(hwnd,IDC_RICHEDIT1, shortPath);
}
}
case IDC_BUTTON1:
{
char buf[MAX_PATH+10];
mciSendString("play %s",buf,sizeof(buf),NULL);
MessageBox(hwnd,"","",MB_OK);
}break;
case IDC_BUTTON2:
{
char buf[MAX_PATH+10];
mciSendString("pause %s",buf,sizeof(buf),NULL);
//MessageBox(hwnd,"","",MB_OK);
}break;
}
这是一个很不完整的播放器,首先打开添加文件后,就播放音乐,我的播放控制键没有用,暂停也没有用,本人是初学者,希望高手指正啊,。就发这里吧,让更多的初学者看一下,谢谢拉,不好意思啊,我没有财富值啊 展开
{
switch(id)
{
case IDC_OK:
{
OPENFILENAME ofn;
char szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = TEXT('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.TXT\0mp3\0*.mp3\0word\0*.doc\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;//自学能力、探索能力、猜测能力
ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
TCHAR shortPath[MAX_PATH];
GetShortPathName(szFile,shortPath,sizeof(shortPath));
TCHAR cmd[MAX_PATH+10];
wsprintf(cmd,"play %s",shortPath);
//MessageBox(hwnd,shortPath,shortPath,MB_OK);
mciSendString(cmd,"",0,NULL);
SetDlgItemText(hwnd,IDC_RICHEDIT1, shortPath);
}
}
case IDC_BUTTON1:
{
char buf[MAX_PATH+10];
mciSendString("play %s",buf,sizeof(buf),NULL);
MessageBox(hwnd,"","",MB_OK);
}break;
case IDC_BUTTON2:
{
char buf[MAX_PATH+10];
mciSendString("pause %s",buf,sizeof(buf),NULL);
//MessageBox(hwnd,"","",MB_OK);
}break;
}
这是一个很不完整的播放器,首先打开添加文件后,就播放音乐,我的播放控制键没有用,暂停也没有用,本人是初学者,希望高手指正啊,。就发这里吧,让更多的初学者看一下,谢谢拉,不好意思啊,我没有财富值啊 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询