版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
./第一步:打開vc6.0,建立如圖所示mfc工程文件選擇基于對(duì)話框的確定刪除所有空間,建立如圖所示對(duì)話框?qū)傩匀缦拢翰シ臝DC_open;添加IDC_fileopen;暫停IDC_pause;刪除IDC_del;停止IDC_stop;退出IDC_exit;音樂名編輯框IDC_filename;音量控制滑塊IDC_SLIDER1;音量控制編輯框IDC_vol;建立類向?qū)?duì)應(yīng)如下:在工程文件,右鍵,插入,bitmap位圖引入你想插入的背景圖,必須是bmp格式的進(jìn)入你的dlg.cpp文件在onpaint函數(shù)下添加代碼voidCMp3Dlg::OnPaint<>{ if<IsIconic<>> { CPaintDCdc<this>;//devicecontextforpainting SendMessage<WM_ICONERASEBKGND,<WPARAM>dc.GetSafeHdc<>,0>; //Centericoninclientrectangle intcxIcon=GetSystemMetrics<SM_CXICON>; intcyIcon=GetSystemMetrics<SM_CYICON>; CRectrect; GetClientRect<&rect>; intx=<rect.Width<>-cxIcon+1>/2; inty=<rect.Height<>-cyIcon+1>/2; //Drawtheicon dc.DrawIcon<x,y,m_hIcon>; } else { //CDialog::OnPaint<>; CPaintDCdc<this>; CRectrect; GetClientRect<&rect>; CDCdcMem; dcMem.CreateCompatibleDC<&dc>; CBitmapbmpBackground; bmpBackground.LoadBitmap<IDB_BITMAP6>;/IDB_BITMAP6是你的位圖地址 BITMAPbitmap; bmpBackground.GetBitmap<&bitmap>; CBitmap*pbmpOld=dcMem.SelectObject<&bmpBackground>; dc.StretchBlt<0,0,rect.Width<>,rect.Height<>,&dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY>; }}編譯運(yùn)行,你就會(huì)看到背景有圖片了。插入-類,找到geneticclass,類名mp3.cpp你會(huì)發(fā)現(xiàn)在頭文件中多了一個(gè)mp3.h文件在mp3.h文件中添加代碼如下//Mp3.h:interfacefortheMp3class.////////////////////////////////////////////////////////////////////////#if!defined<AFX_MP3_H__20D325E5_A96A_43FE_A485_92F57C68DD0D__INCLUDED_>#defineAFX_MP3_H__20D325E5_A96A_43FE_A485_92F57C68DD0D__INCLUDED_#if_MSC_VER>1000#pragmaonce#endif//_MSC_VER>1000#include"Mmsystem.h"classMp3{public: Mp3<>; virtual~Mp3<>;HWNDm_hWnd;//????μ±?°′°?úμ???±ú DWORDDeviceID;//???¨2¥·?ò?à?μ?éè±?IDMCI_OPEN_PARMSmciopenparms;//???¨′ò?aò?à????tμ?2?êyvoidLoad<HWNDhwnd,CStringStrfilepath>; DWORDgetinformation<DWORDitem>; voidPlay<>; voidPause<>; voidresum<>; voidStop<>;};#endif//!defined<AFX_MP3_H__20D325E5_A96A_43FE_A485_92F57C68DD0D__INCLUDED_>在mp3.cpp中添加如下代碼//Mp3.cpp:implementationoftheMp3class.////////////////////////////////////////////////////////////////////////#include"stdafx.h"#include"Mp32¥·??÷.h"#include"Mp3.h"#ifdef_DEBUG#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#definenewDEBUG_NEW#endif////////////////////////////////////////////////////////////////////////Construction/Destruction//////////////////////////////////////////////////////////////////////Mp3::Mp3<>{}Mp3::~Mp3<>{}voidMp3::Load<HWNDhwnd,CStringStrfilepath>{ m_hWnd=hwnd; mciSendCommand<DeviceID,MCI_CLOSE,0,0>;//?ó?????t?°?è??3yé?′?éè?? mciopenparms.lpstrElementName=Strfilepath;//??ò?à????t?·??′???éè±? DWORDdwReturn; if<dwReturn=mciSendCommand<NULL,MCI_OPEN,MCI_OPEN_ELEMENT|MCI_WAIT,<DWORD><LPVOID>&mciopenparms>> { //è?1?′ò?a꧰ü£???3?′íD??¢′??úbuffer2¢??ê?3?′í?ˉ?? charbuffer[256]; mciGetErrorString<dwReturn,buffer,256>; MessageBox<hwnd,buffer,"3?′í?ˉ??",MB_ICONHAND|MB_ICONERROR|MB_ICONSTOP>; } DeviceID=mciopenparms.wDeviceID;//?à??ì?éè±?ààDí±ào?}DWORDMp3::getinformation<DWORDitem>{ //MCI?ó?ú???óμ?×′ì? MCI_STATUS_PARMSmcistatusparms; //′y??è?μ????? mcistatusparms.dwItem=item; mcistatusparms.dwReturn=0; //???à??ì?éè±?·¢?í??á?£???è?μ±?°μ?×′ì?2?êy mciSendCommand<DeviceID,MCI_STATUS,MCI_STATUS_ITEM,<DWORD>&mcistatusparms>; returnmcistatusparms.dwReturn;}voidMp3::Play<>{ MCI_PLAY_PARMSmciplayparms; mciplayparms.dwCallback=<DWORD>m_hWnd; mciplayparms.dwFrom=0;//??′?′óí·2¥·? mciSendCommand<DeviceID,MCI_PLAY,MCI_FROM|MCI_NOTIFY,<DWORD><LPVOID>&mciplayparms>;}voidMp3::Pause<>{ mciSendCommand<DeviceID,MCI_PAUSE,0,0>;}voidMp3::resum<>{ mciSendCommand<DeviceID,MCI_RESUME,0,0>;}voidMp3::Stop<>{ mciSendCommand<DeviceID,MCI_STOP,0,0>; mciSendCommand<DeviceID,MCI_CLOSE,0,0>;}在dlg.cpp文件的public中添加一行代碼:inthour,minute,second;在CMp3Dlg::CMp3Dlg<CWnd*pParent/*=NULL*/>中添加如下CMp3Dlg::CMp3Dlg<CWnd*pParent/*=NULL*/> :CDialog<CMp3Dlg::IDD,pParent>{ //{{AFX_DATA_INIT<CMp3Dlg> m_int=0; //}}AFX_DATA_INIT //NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32 m_hIcon=AfxGetApp<>->LoadIcon<IDI_ICON1>; hour=0;minute=0;second=0;}dlg.cpp中頭文件如下:#include"stdafx.h"#include"Mp32¥·??÷.h"#include"Mp32¥·??÷Dlg.h"#include"Mmsystem.h"#include"Digitalv.h"#include"Mp3.h"http://ò?á?????ó?μ?#pragmacomment<lib,"Winmm.lib">#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif在對(duì)話框中雙擊添加添加onfileopen函數(shù),代碼如下voidCMp3Dlg::Onfileopen<>{ charfilefiler[]="mp3文件<*.mp3>|*.mp3|" "wma文件<*.wma>|*.wma|" "wav文件<*.wav>|*.wav|"; CFileDialogdlg<true,NULL,NULL,OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLESIZING,filefiler>;if<dlg.DoModal<>==IDOK>{ CStringstrfilepath=dlg.GetPathName<>; CStringstrfilename=dlg.GetFileName<>; SetDlgItemText<IDC_filename,strfilename>; CStringmtime; CClientDCdc<this>; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; Mp3mp3; mp3.Load<this->m_hWnd,strfilepath>; GetDlgItem<IDC_open>->EnableWindow<TRUE>; GetDlgItem<IDC_pause>->EnableWindow<TRUE>; GetDlgItem<IDC_stop>->EnableWindow<TRUE>; GetDlgItem<IDC_del>->EnableWindow<TRUE>;m_list.InsertString<m_list.GetCount<>,strfilename>;//獲取文件名m_list.SetCurSel<m_list.GetCount<>-1>;}雙擊播放,進(jìn)入代碼,添加如下voidCMp3Dlg::Onopen<>{ CStringstrfilename; intindex=m_list.GetCurSel<>; CStringmtime; CClientDCdc<this>; Mp3mp3; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; if<index==-1> { MessageBox<"請(qǐng)?zhí)砑右魳?>; return; } m_list.GetText<index,strfilename>; SetDlgItemText<IDC_filename,strfilename>;mp3.Stop<>; mp3.Load<this->m_hWnd,strfilename>; mp3.Play<>;SetTimer<0,1000,NULL>;}同理,暫停,停止,刪除,退出代碼如下voidCMp3Dlg::Onpause<>{ //TODO:Addyourcontrolnotificationhandlercodehere CStringstrtemp; Mp3mp3; GetDlgItemText<IDC_pause,strtemp>;//獲取按鈕狀態(tài) if<strtemp.Compare<"暫停">==0> { mp3.Pause<>; SetDlgItemText<IDC_pause,"繼續(xù)">; KillTimer<0>;//取消計(jì)數(shù)器的顯示 } if<strtemp.Compare<"繼續(xù)">==0> { mp3.resum<>; SetTimer<0,1000,NULL>; SetDlgItemText<IDC_pause,"暫停">; }}voidCMp3Dlg::Onstop<>{ //TODO:Addyourcontrolnotificationhandlercodehere Mp3mp3; mp3.Stop<>; SetDlgItemText<IDC_pause,"暫停">; KillTimer<0>;//取消計(jì)數(shù)器的顯示 CStringmtime; CClientDCdc<this>; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; GetDlgItem<IDC_open>->EnableWindow<FALSE>; GetDlgItem<IDC_pause>->EnableWindow<FALSE>; GetDlgItem<IDC_stop>->EnableWindow<FALSE>; GetDlgItem<IDC_del>->EnableWindow<FALSE>;}voidCMp3Dlg::Ondel<>{ UpdateData<TRUE>; Mp3mp3; intindex=m_list.GetCurSel<>; mp3.Stop<>; SetDlgItemText<IDC_filename,"">; KillTimer<0>; hour=0;minute=0;second=0;//歌曲時(shí)間置0 if<index!=CB_ERR> { m_list.DeleteString<index>; }}voidCMp3Dlg::Onexit<>{ //TODO:Addyourcontrolnotificationhandlercodehere CDialog::OnCancel<>;}ctrl+w打開類向?qū)?如圖,添加ontimer函數(shù)代碼如下:voidCMp3Dlg::OnTimer<UINTnIDEvent>{ //TODO:Addyourmessagehandlercodehereand/orcalldefault CStringmtime; Mp3mp3; second++; CClientDCdc<this>; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色if<second==60>//設(shè)置鐘表的顯示 { minute++;second=0; } if<minute==60> { hour++;minute=0; } mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; DWORDcdf=mp3.getinformation<MCI_STATUS_POSITION>; DWORDcdfrom; cdfrom=MCI_MAKE_MSF<MCI_MSF_MINUTE<cdf>,MCI_MSF_SECOND<cdf>,MCI_MSF_FRAME<cdf>>;//獲取當(dāng)前播放文件的信息 UpdateData<false>; CDialog::OnTimer<nIDEvent>;}ctrl+w打開類向?qū)砑雍瘮?shù)如下voidCMp3Dlg::OnDblclkList<>//在列表中選中,雙擊左鍵播放音樂{ CStringmtime; Mp3mp3; CClientDCdc<this>; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; CStringstrfilename; intindex=m_list.GetCurSel<>; m_list.GetText<index,strfilename>; SetDlgItemText<IDC_filename,strfilename>; mp3.Stop<>; mp3.Load<this->m_hWnd,strfilename>; mp3.Play<>;SetTimer<0,1000,NULL>; }打開類向?qū)?添加函數(shù)如下voidCMp3Dlg::OnCustomdrawSlider1<NMHDR*pNMHDR,LRESULT*pResult>{ //TODO:Addyourcontrolnotificationhandlercodehere UpdateData<true>; m_int=m_slider.GetPos<>/10; Setvolumn<m_slider.GetPos<>>; UpdateData<false>; *pResult=0;}打開類向?qū)?添加函數(shù)如下voidCMp3Dlg::OnReleasedcaptureSlider1<NMHDR*pNMHDR,LRESULT*pResult>{ //TODO:Addyourcontrolnotificationhandlercodehere Setvolumn<m_slider.GetPos<>>; *pResult=0;}添加聲音設(shè)置函數(shù)如下DWORDCMp3Dlg::Setvolumn<DWORDvol>{ MCI_DGV_SETAUDIO_PARMSmcisetvolumn; mcisetvolumn.dwCallback=NULL; mcisetvolumn.dwItem=MCI_DGV_SETAUDIO_VOLUME; mcisetvolumn.dwValue=vol;MCI_OPEN_PARMSmciopenparms; DWORDDeviceID; DeviceID=mciopenparms.wDeviceID; mciSendCommand<DeviceID,MCI_SETAUDIO,MCI_DGV_SETAUDIO_VALUE|MCI_DGV_SETAUDIO_ITEM,<DWORD><LPVOID>&mcisetvolumn>; // returnmcisetvolumn.dwValue; return0;}到此已經(jīng)基本完成了,我們可以試聽一下接下來我們可以到包成exe可執(zhí)行文件,為了去掉那個(gè)不好看的圖標(biāo),我們可以進(jìn)入res文件夾,把原來的圖標(biāo)刪掉,不過,你要放入一個(gè)cio格式的圖片作為圖標(biāo),cio格式網(wǎng)上有很多轉(zhuǎn)換的,刪掉原圖標(biāo)后,程序會(huì)自動(dòng)生成一個(gè)你放進(jìn)去的圖標(biāo)。接下來演示打包:工程,設(shè)置,或者按alt+f7,如圖設(shè)置組建,批組建,如圖創(chuàng)建完成后,你就會(huì)發(fā)現(xiàn)在你的工程文件中多了一個(gè)release文件夾,打開找到exe,這個(gè)文件就是打包好的,隨便放到哪里都可以執(zhí)行,至此,工作基本完成了,最后附上源代碼,僅供參考dlg.cpp文件//Mp3播放器Dlg.cpp:implementationfile//#include"stdafx.h"#include"Mp3播放器.h"#include"Mp3播放器Dlg.h"#include"Mmsystem.h"#include"Digitalv.h"#include"Mp3.h"http://音量控制用到#pragmacomment<lib,"Winmm.lib">#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CAboutDlgdialogusedforAppAboutclassCAboutDlg:publicCDialog{public: CAboutDlg<>;//DialogData //{{AFX_DATA<CAboutDlg> enum{IDD=IDD_ABOUTBOX}; //}}AFX_DATA //ClassWizardgeneratedvirtualfunctionoverrides //{{AFX_VIRTUAL<CAboutDlg> protected: virtualvoidDoDataExchange<CDataExchange*pDX>;//DDX/DDVsupport //}}AFX_VIRTUAL//Implementationprotected: //{{AFX_MSG<CAboutDlg> //}}AFX_MSG DECLARE_MESSAGE_MAP<>};CAboutDlg::CAboutDlg<>:CDialog<CAboutDlg::IDD>{ //{{AFX_DATA_INIT<CAboutDlg> //}}AFX_DATA_INIT}voidCAboutDlg::DoDataExchange<CDataExchange*pDX>{ CDialog::DoDataExchange<pDX>; //{{AFX_DATA_MAP<CAboutDlg> //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP<CAboutDlg,CDialog> //{{AFX_MSG_MAP<CAboutDlg> //Nomessagehandlers //}}AFX_MSG_MAPEND_MESSAGE_MAP<>///////////////////////////////////////////////////////////////////////////////CMp3DlgdialogCMp3Dlg::CMp3Dlg<CWnd*pParent/*=NULL*/> :CDialog<CMp3Dlg::IDD,pParent>{ //{{AFX_DATA_INIT<CMp3Dlg> m_int=0; //}}AFX_DATA_INIT //NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32 m_hIcon=AfxGetApp<>->LoadIcon<IDI_ICON1>; hour=0;minute=0;second=0;}voidCMp3Dlg::DoDataExchange<CDataExchange*pDX>{ CDialog::DoDataExchange<pDX>; //{{AFX_DATA_MAP<CMp3Dlg> DDX_Control<pDX,IDC_LIST,m_list>; DDX_Control<pDX,IDC_SLIDER1,m_slider>; DDX_Text<pDX,IDC_vol,m_int>; //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP<CMp3Dlg,CDialog> //{{AFX_MSG_MAP<CMp3Dlg> ON_WM_SYSCOMMAND<> ON_WM_PAINT<> ON_WM_QUERYDRAGICON<> ON_BN_CLICKED<ID_exit,Onexit> ON_NOTIFY<NM_CUSTOMDRAW,IDC_SLIDER1,OnCustomdrawSlider1> ON_BN_CLICKED<IDC_fileopen,Onfileopen> ON_BN_CLICKED<IDC_open,Onopen> ON_BN_CLICKED<IDC_pause,Onpause> ON_BN_CLICKED<IDC_stop,Onstop> ON_NOTIFY<NM_RELEASEDCAPTURE,IDC_SLIDER1,OnReleasedcaptureSlider1> ON_WM_TIMER<> ON_BN_CLICKED<IDC_del,Ondel> ON_LBN_DBLCLK<IDC_LIST,OnDblclkList> //}}AFX_MSG_MAPEND_MESSAGE_MAP<>///////////////////////////////////////////////////////////////////////////////CMp3DlgmessagehandlersBOOLCMp3Dlg::OnInitDialog<>{ CDialog::OnInitDialog<>; //Add"About..."menuitemtosystemmenu. //IDM_ABOUTBOXmustbeinthesystemcommandrange. ASSERT<<IDM_ABOUTBOX&0xFFF0>==IDM_ABOUTBOX>; ASSERT<IDM_ABOUTBOX<0xF000>; CMenu*pSysMenu=GetSystemMenu<FALSE>; if<pSysMenu!=NULL> { CStringstrAboutMenu; strAboutMenu.LoadString<IDS_ABOUTBOX>; if<!strAboutMenu.IsEmpty<>> { pSysMenu->AppendMenu<MF_SEPARATOR>; pSysMenu->AppendMenu<MF_STRING,IDM_ABOUTBOX,strAboutMenu>; } } //Settheiconforthisdialog.Theframeworkdoesthisautomatically //whentheapplication'smainwindowisnotadialog SetIcon<m_hIcon,TRUE>; //Setbigicon SetIcon<m_hIcon,FALSE>;//Setsmallicon SetWindowText<"MP3播放器">; MoveWindow<250,150,580,500>;//顯示時(shí)間控制 m_slider.SetRange<0,1000>;//移動(dòng)圍 m_slider.SetPos<500>;//滑塊指針的初始位置 GetDlgItem<IDC_open>->EnableWindow<FALSE>; GetDlgItem<IDC_pause>->EnableWindow<FALSE>; GetDlgItem<IDC_stop>->EnableWindow<FALSE>; GetDlgItem<IDC_del>->EnableWindow<FALSE>; //TODO:Addextrainitializationhere returnTRUE;//returnTRUEunlessyousetthefocustoacontrol}voidCMp3Dlg::OnSysCommand<UINTnID,LPARAMlParam>{ if<<nID&0xFFF0>==IDM_ABOUTBOX> { CAboutDlgdlgAbout; dlgAbout.DoModal<>; } else { CDialog::OnSysCommand<nID,lParam>; }}//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.voidCMp3Dlg::OnPaint<>{ if<IsIconic<>> { CPaintDCdc<this>;//devicecontextforpainting SendMessage<WM_ICONERASEBKGND,<WPARAM>dc.GetSafeHdc<>,0>; //Centericoninclientrectangle intcxIcon=GetSystemMetrics<SM_CXICON>; intcyIcon=GetSystemMetrics<SM_CYICON>; CRectrect; GetClientRect<&rect>; intx=<rect.Width<>-cxIcon+1>/2; inty=<rect.Height<>-cyIcon+1>/2; //Drawtheicon dc.DrawIcon<x,y,m_hIcon>; } else { //CDialog::OnPaint<>; CPaintDCdc<this>; CRectrect; GetClientRect<&rect>; CDCdcMem; dcMem.CreateCompatibleDC<&dc>; CBitmapbmpBackground; bmpBackground.LoadBitmap<IDB_BITMAP6>; BITMAPbitmap; bmpBackground.GetBitmap<&bitmap>; CBitmap*pbmpOld=dcMem.SelectObject<&bmpBackground>; dc.StretchBlt<0,0,rect.Width<>,rect.Height<>,&dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY>; }}//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.HCURSORCMp3Dlg::OnQueryDragIcon<>{ return<HCURSOR>m_hIcon;}voidCMp3Dlg::Onexit<>{ //TODO:Addyourcontrolnotificationhandlercodehere CDialog::OnCancel<>;}voidCMp3Dlg::OnCustomdrawSlider1<NMHDR*pNMHDR,LRESULT*pResult>{ //TODO:Addyourcontrolnotificationhandlercodehere UpdateData<true>; m_int=m_slider.GetPos<>/10; Setvolumn<m_slider.GetPos<>>; UpdateData<false>; *pResult=0;}voidCMp3Dlg::Onfileopen<>{ charfilefiler[]="mp3文件<*.mp3>|*.mp3|" "wma文件<*.wma>|*.wma|" "wav文件<*.wav>|*.wav|"; CFileDialogdlg<true,NULL,NULL,OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLESIZING,filefiler>;if<dlg.DoModal<>==IDOK>{ CStringstrfilepath=dlg.GetPathName<>; CStringstrfilename=dlg.GetFileName<>; SetDlgItemText<IDC_filename,strfilename>; CStringmtime; CClientDCdc<this>; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; Mp3mp3; mp3.Load<this->m_hWnd,strfilepath>; GetDlgItem<IDC_open>->EnableWindow<TRUE>; GetDlgItem<IDC_pause>->EnableWindow<TRUE>; GetDlgItem<IDC_stop>->EnableWindow<TRUE>; GetDlgItem<IDC_del>->EnableWindow<TRUE>;m_list.InsertString<m_list.GetCount<>,strfilename>;//獲取文件名m_list.SetCurSel<m_list.GetCount<>-1>;}}voidCMp3Dlg::Onopen<>{ CStringstrfilename; intindex=m_list.GetCurSel<>; CStringmtime; CClientDCdc<this>; Mp3mp3; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; if<index==-1> { MessageBox<"請(qǐng)?zhí)砑右魳?>; return; } m_list.GetText<index,strfilename>; SetDlgItemText<IDC_filename,strfilename>;mp3.Stop<>; mp3.Load<this->m_hWnd,strfilename>; mp3.Play<>;SetTimer<0,1000,NULL>;}voidCMp3Dlg::Onpause<>{ //TODO:Addyourcontrolnotificationhandlercodehere CStringstrtemp; Mp3mp3; GetDlgItemText<IDC_pause,strtemp>;//獲取按鈕狀態(tài) if<strtemp.Compare<"暫停">==0> { mp3.Pause<>; SetDlgItemText<IDC_pause,"繼續(xù)">; KillTimer<0>;//取消計(jì)數(shù)器的顯示 } if<strtemp.Compare<"繼續(xù)">==0> { mp3.resum<>; SetTimer<0,1000,NULL>; SetDlgItemText<IDC_pause,"暫停">; }}voidCMp3Dlg::Onstop<>{ //TODO:Addyourcontrolnotificationhandlercodehere Mp3mp3; mp3.Stop<>; SetDlgItemText<IDC_pause,"暫停">; KillTimer<0>;//取消計(jì)數(shù)器的顯示 CStringmtime; CClientDCdc<this>; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; GetDlgItem<IDC_open>->EnableWindow<FALSE>; GetDlgItem<IDC_pause>->EnableWindow<FALSE>; GetDlgItem<IDC_stop>->EnableWindow<FALSE>; GetDlgItem<IDC_del>->EnableWindow<FALSE>;}DWORDCMp3Dlg::Setvolumn<DWORDvol>{ MCI_DGV_SETAUDIO_PARMSmcisetvolumn; mcisetvolumn.dwCallback=NULL; mcisetvolumn.dwItem=MCI_DGV_SETAUDIO_VOLUME; mcisetvolumn.dwValue=vol;MCI_OPEN_PARMSmciopenparms; DWORDDeviceID; DeviceID=mciopenparms.wDeviceID; mciSendCommand<DeviceID,MCI_SETAUDIO,MCI_DGV_SETAUDIO_VALUE|MCI_DGV_SETAUDIO_ITEM,<DWORD><LPVOID>&mcisetvolumn>; // returnmcisetvolumn.dwValue; return0;}voidCMp3Dlg::OnReleasedcaptureSlider1<NMHDR*pNMHDR,LRESULT*pResult>{ //TODO:Addyourcontrolnotificationhandlercodehere Setvolumn<m_slider.GetPos<>>; *pResult=0;}voidCMp3Dlg::OnTimer<UINTnIDEvent>{ //TODO:Addyourmessagehandlercodehereand/orcalldefault CStringmtime; Mp3mp3; second++; CClientDCdc<this>; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色if<second==60>//設(shè)置鐘表的顯示 { minute++;second=0; } if<minute==60> { hour++;minute=0; } mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; DWORDcdf=mp3.getinformation<MCI_STATUS_POSITION>; DWORDcdfrom; cdfrom=MCI_MAKE_MSF<MCI_MSF_MINUTE<cdf>,MCI_MSF_SECOND<cdf>,MCI_MSF_FRAME<cdf>>;//獲取當(dāng)前播放文件的信息 UpdateData<false>; CDialog::OnTimer<nIDEvent>;}voidCMp3Dlg::Ondel<>{ UpdateData<TRUE>; Mp3mp3; intindex=m_list.GetCurSel<>; mp3.Stop<>; SetDlgItemText<IDC_filename,"">; KillTimer<0>; hour=0;minute=0;second=0;//歌曲時(shí)間置0 if<index!=CB_ERR> { m_list.DeleteString<index>; }}voidCMp3Dlg::OnDblclkList<>{ CStringmtime; Mp3mp3; CClientDCdc<this>; hour=0;minute=0;second=0; dc.SetBkColor<RGB<124,252,0>>;//設(shè)置放置計(jì)數(shù)器區(qū)域的外觀 dc.SetTextColor<RGB<255,255,203>>;//設(shè)置數(shù)字顯示的顏色 mtime.Format<"%02d:%02d:%02d",hour,minute,second>;//顯示時(shí)間進(jìn)度 dc.TextOut<280,128,mtime>; CStringstrfilename; intindex=m_list.GetCurSel<>; m_list.GetText<index,strfilename>; SetDlgItemText<IDC_filename,strfilename>; mp3.Stop<>; mp3.Load<this->m_hWnd,strfilename>; mp3.Play<>;SetTimer<0,1000,NULL>; }mp3.cpp文件//Mp3.cpp:implementationoftheMp3class.////////////////////////////////////////////////////////////////////////#include"stdafx.h"#include"Mp3播放器.h"#include"Mp3.h"#ifdef_DEBUG#unde
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 漯河食品職業(yè)學(xué)院《公共關(guān)系學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 2025年汕頭交通運(yùn)輸從業(yè)資格證怎樣考試
- 2024年新三板股份購買合同專業(yè)模板版B版
- 2024年二零二四年度鐵藝大門安裝與保養(yǎng)服務(wù)合同3篇
- 2025年恩施貨運(yùn)從業(yè)資格證考試題庫
- 2024年標(biāo)準(zhǔn)水泥穩(wěn)定碎石層施工合作合同一
- 2024年度特色小鎮(zhèn)商品房買賣合同GF-01713篇
- 2024年建筑腳手架租賃及保險(xiǎn)合同標(biāo)準(zhǔn)范本版B版
- 兒童生長發(fā)育診所醫(yī)生招聘合同
- 城市防毒施工合同
- 國開2023年春《人文英語4》機(jī)考網(wǎng)考期末復(fù)習(xí)資料參考答案
- DB3716-T 27-2023鄉(xiāng)鎮(zhèn)級(jí)應(yīng)急物資配備指南
- 員工食堂承包合同、考核細(xì)則、考核評(píng)分表
- 小學(xué)生相聲劇本(10篇)
- 2023-2024學(xué)年山東省膠州市初中語文九年級(jí)上冊(cè)期末自測(cè)測(cè)試題
- 人力資源專員招聘筆試題
- LY/T 1646-2005森林采伐作業(yè)規(guī)程
- GB/T 7531-2008有機(jī)化工產(chǎn)品灼燒殘?jiān)臏y(cè)定
- GB/T 19963.1-2021風(fēng)電場(chǎng)接入電力系統(tǒng)技術(shù)規(guī)定第1部分:陸上風(fēng)電
- GB/T 13586-2006鋁及鋁合金廢料
- 二年級(jí)上冊(cè)數(shù)學(xué)試題-應(yīng)用題復(fù)習(xí)6-人教新課標(biāo)(2014秋)(無答案)
評(píng)論
0/150
提交評(píng)論