2008年(909)
分类:
2008-05-06 21:34:45
void CSunapplerealplayerDlg::OnOpen() { char szFileFilter[]= "RM File(*.rm)|*.rm|" "Mp3 File(*.mp3)|*.mp3|" "MPEG File(*.mpeg)|*.mpeg|" "Media File(*.asf)|*.asf|" "Video File(*.dat)|*.dat|" "MPGA File(*.mpga)|*.mpga|" "Wave File(*.wav)|*.wav|" "AVI File(*.avi)|*.avi|" "Movie File(*.mov)|*.mov|" "Mid File(*.mid;*,rmi)|*.mid;*.rmi|" "Wma File(*.wma)|*.wma|" "All File(*.*)|*.*||"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter); if(dlg.DoModal()==IDOK){ CString PathName=dlg.GetPathName(); PathName.MakeUpper(); m_player->SetSource(PathName); m_player->DoPlay(); SetDlgItemText(IDC_STATIC1,m_player->GetAuthor()); SetDlgItemText(IDC_STATIC2,m_player->GetTitle()); SetDlgItemText(IDC_COPYRIGHT,m_player->GetCopyright()); SetDlgItemText(IDC_SOURCE,m_player->GetSource()); } } void CSunapplerealplayerDlg::OnPlay() { SetDlgItemText(IDC_STATIC1,m_player->GetAuthor()); SetDlgItemText(IDC_STATIC2,m_player->GetTitle()); SetDlgItemText(IDC_COPYRIGHT,m_player->GetCopyright()); SetDlgItemText(IDC_SOURCE,m_player->GetSource()); m_player->DoPlay(); UpdateData(false); SetTimer(1,20,NULL); } void CSunapplerealplayerDlg::OnTimer(UINT nIDEvent) { if(0&&isRepeat) m_player->DoPlay(); CDialog::OnTimer(nIDEvent); } void CSunapplerealplayerDlg::OnClose() { ///////添加此代码时不要忘了在stdafx.h开头处添加前两行 AnimateWindow(GetSafeHwnd(),1000,AW_HIDE|AW_BLEND); KillTimer(0); //////////////////////////////////// //此处采用DestroyWindow关闭窗口 //多谢杜修杏 老师指点 /////////////////////////////////// this->DestroyWindow(); } void CSunapplerealplayerDlg::OnFullscreen() { m_player->DoPause(); m_player->SetFullScreen(); m_player->DoPlay(); } void CSunapplerealplayerDlg::OnMp3down() { ShellExecute(NULL,_T("open"),"",NULL,NULL,TRUE); } void CSunapplerealplayerDlg::OnPause() { m_player->DoPause(); } void CSunapplerealplayerDlg::OnStop() { m_player->DoStop(); KillTimer(0); } void CSunapplerealplayerDlg::OnRepeat() { m_player->SetLoop(true); if(isRepeat){ isRepeat=FALSE; SetDlgItemText(IDC_REPEAT,"循环"); } else { isRepeat=TRUE; SetDlgItemText(IDC_REPEAT,"正常"); } } void CSunapplerealplayerDlg::OnLower() { // TODO: Add your control notification handler code here short volume=m_player->GetVolume(); m_player->DoPause(); m_player->SetVolume(volume-100); m_player->DoPlay(); } void CSunapplerealplayerDlg::OnUpper() { // TODO: Add your control notification handler code here short volume=m_player->GetVolume(); m_player->DoPause(); m_player->SetVolume(volume 100); m_player->DoPlay(); } void CSunapplerealplayerDlg::OnFloat() { // TODO: Add your command handler code here ShellExecute(NULL,_T("open"),"",NULL,NULL,TRUE); } void CSunapplerealplayerDlg::OnPetroleum() { // TODO: Add your command handler code here ShellExecute(NULL,_T("open"),"",NULL,NULL,TRUE); }五、映射WM_CTLCOLOR消息,用于控制文本显示的颜色
HBRUSH CSunapplerealplayerDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if(nCtlColor==CTLCOLOR_STATIC) if(pWnd.GetDlgCtrlID()==IDC_VOLUME) { pDC.SetTextColor(RGB(165,182,222)); pDC.SetBkMode(TRANSPARENT); return (HBRUSH) m_brush.GetSafeHandle(); } if(pWnd.GetDlgCtrlID()==IDC_STATIC1||pWnd.GetDlgCtrlID()==IDC_STATIC2 ||pWnd.GetDlgCtrlID()==IDC_SOURCE||pWnd.GetDlgCtrlID()==IDC_COPYRIGHT) { pDC.SetTextColor(RGB(0,0,255)); pDC.SetBkMode(TRANSPARENT); return (HBRUSH) m_brush.GetSafeHandle(); } if(pWnd.GetDlgCtrlID()==IDC_STATIC||pWnd.GetDlgCtrlID()==IDC_INFO) { pDC.SetTextColor(RGB(255,0,0)); pDC.SetBkMode(TRANSPARENT); return (HBRUSH) m_brush.GetSafeHandle(); } // TODO: Return a different brush if the default is not desired return hbr; }六、在APP类里的initInstance()里添加下面函数改变对话框背景。
SetDialogBkColor(RGB(206,227,99));七、为了美观我们的外形可引入CButtonXP类,将个按钮类型设置为CButtonXP