⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winsurgedlg.cpp

📁 winsur 源码 winsur 源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	this->m_addf.SetBitmap(IDB_OPENF);
	this->m_loop.SetBitmap(IDB_GOON);
	this->m_nextf.SetBitmap(IDB_LAST);
	this->m_nexts.SetBitmap(IDB_STEP);
	this->m_pause.SetBitmap(IDB_PAUSE);
	this->m_play.SetBitmap(IDB_PLAY);
	this->m_stop.SetBitmap(IDB_STOP);
	this->m_list.SetBitmap(IDB_LIST);
	this->m_lastf.SetBitmap(IDB_NEXT);
	this->m_lasts.SetBitmap(IDB_LASTSTEP);

	
	m_tooltip.AddTool(&m_play, _T("播放"));
	m_tooltip.AddTool(&m_pause, _T("暂停"));
	m_tooltip.AddTool(&m_stop, _T("停止"));
	m_tooltip.AddTool(&m_addf, _T("添加歌曲"));
	m_tooltip.AddTool(&m_loop, _T("循环/顺序播放"));
	m_tooltip.AddTool(&m_nextf, _T("下一首"));
	m_tooltip.AddTool(&m_nexts, _T("下一步"));
	m_tooltip.AddTool(&m_list, _T("曲目列表"));
	m_tooltip.AddTool(&m_lastf, _T("上一首"));
	m_tooltip.AddTool(&m_lasts, _T("上一步"));
	m_tooltip.AddTool(GetDlgItem(IDC_SLIDER),_T("播放进度  [当前风格:\""+m_type+"\",双击右键改变风格]"));
}

void CWinSurgeDlg::OnLaststep() 
{
	// TODO: Add your control notification handler code here
	DWORD dwp;
	DWORD dwl;
	m_mci.MCIGetLength(&dwl);
	m_mci.MCIGetPos(&dwp);
	m_mci.MCISeekTo(dwp-dwl/100);
	m_mci.MCIPlay();
}

void CWinSurgeDlg::OnNextstep() 
{
	// TODO: Add your control notification handler code here
	DWORD dwp;
	DWORD dwl;
	m_mci.MCIGetLength(&dwl);
	m_mci.MCIGetPos(&dwp);
	m_mci.MCISeekTo(dwp+dwl/100);
	m_mci.MCIPlay();
}

void CWinSurgeDlg::OnLoop() 
{
	// TODO: Add your control notification handler code here
	if(m_loopf==FALSE)
	{
		m_loopf=TRUE;
		//this->m_loop.SetPic("face\\"+m_type+"\\buttonbg.bmp",IDB_LOOP);
		this->m_loop.SetBitmap(IDB_LOOP);
	}
	else
	{
		m_loopf=FALSE;
		//this->m_loop.SetPic("face\\"+m_type+"\\buttonbg.bmp",IDB_GOON);
		this->m_loop.SetBitmap(IDB_LOOP);
	}
}

void CWinSurgeDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if (pScrollBar->GetDlgCtrlID()==IDC_SLIDER)
	{
		DWORD dwPos=(DWORD)((CSliderCtrl *)pScrollBar)->GetPos();
		m_mci.MCISeekTo(dwPos);
		m_mci.MCIPlay();
	}
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

void CWinSurgeDlg::OnList() 
{
	// TODO: Add your control notification handler code here
		m_listDlg.ShowWindow(SW_SHOW);
		RECT rect1;
		GetWindowRect(&rect1);
		m_listDlg.SetWindowPos(NULL,rect1.left,rect1.bottom,0,0,1);
		m_listDlg.ChangeType(m_type);
}

void CWinSurgeDlg::OnAddsingle() 
{
	// TODO: Add your command handler code here
	CFileDialog addfile(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Mp3文件(*.mp3)|*.mp3|WMA文件(*.wma)|*.wma|所有文件(*.*)|*.*||",NULL);  
	if(addfile.DoModal()==IDOK)
	{
		index=0;
		m_slide.SetRange(0, m_mci.m_dwLength, true);
		m_listDlg.m_list.InsertString(0,addfile.GetPathName());
		open(index);
	}
}

void CWinSurgeDlg::OnAddgroup() 
{
	// TODO: Add your command handler code here
	CString strDirPath=_T("");
	BROWSEINFO bi = {
		this->GetSafeHwnd(),
			NULL,
			strDirPath.GetBuffer(255),
			NULL,//_T("加入目录中的所有MP3文件"),
			0,
			NULL,
			NULL,
			0};
		
		ITEMIDLIST* piid = NULL;
		
		// call the shell function
		piid = :: SHBrowseForFolder(&bi);
		strDirPath.ReleaseBuffer();
		
		// process the result
		if (piid && ::SHGetPathFromIDList(piid, strDirPath.GetBuffer(255)))
		{
			strDirPath.ReleaseBuffer();
			FindFiles(strDirPath);
			index=0;
			open(index);
		}
		else
		{
			return;
		}
}

void CWinSurgeDlg::Play()
{
	m_mci.MCIPlay();
}

void CWinSurgeDlg::Pause()
{
	m_mci.MCIPause();
}

void CWinSurgeDlg::Stop()
{
	m_mci.MCIClose();
	DiStr=LOGOSTR;
	TimeStr="作者:大笨猫";
}

HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	
	// TODO: Return a different brush if the default is not desired
	return  (HBRUSH)m_bkBrush.GetSafeHandle();
}

void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	OnOK();
	CDialog::OnLButtonDown(nFlags, point);
}

void CWinSurgeDlg::open(int i)
{
	CString path;
	m_listDlg.m_list.GetText(i,path);
	m_mci.MCIClose();
	m_mci.MCIOpen(path);
	m_slide.SetRange(0, m_mci.m_dwLength, true);
	m_mci.MCIPlay();
	while(int i=path.Find("\\",0)!=-1)
	{
		i=path.Find("\\",0);
		path=path.Right(path.GetLength()-i-1);
	}
	DiStr=path.Left(path.Find(".",0));
}

BOOL CWinSurgeDlg::PreTranslateMessage(MSG* pMsg)
{
	// CG: The following block was added by the ToolTips component.	{		// Let the ToolTip process this message.		m_tooltip.RelayEvent(pMsg);	}	return CDialog::PreTranslateMessage(pMsg);	// CG: This was added by the ToolTips component.
}

void CWinSurgeDlg::FindFiles(CString DirName)
{
	CFileFind tempFind; 
	char tempFileFind[200];
	memset(tempFileFind,0,200);
	sprintf(tempFileFind,"%s\\*.*",DirName); 
	BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind); 
	while(IsFinded)
	{ 
		IsFinded=(BOOL)tempFind.FindNextFile(); 
		if(!tempFind.IsDots()) 
		{ 
			char foundFileName[200];
			memset(foundFileName,0,200);
			strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));
			if(!tempFind.IsDirectory()) 
			{
				CString temp=foundFileName;
				if((temp.Right(4)==".mp3")
					||(temp.Right(4)==".MP3")
					||(temp.Right(4)==".Mp3")
					||(temp.Right(4)==".mP3")
					||(temp.Right(4)==".mp3")
					||(temp.Right(4)==".WMA")
					||(temp.Right(4)==".wma")
					||(temp.Right(4)==".Wma"))
				{
					m_listDlg.m_list.InsertString(0,tempFind.GetFilePath());
				}
			}
			else
			{
				FindFiles(tempFind.GetFilePath());
			}
		}
	}
	tempFind.Close();
}

void CWinSurgeDlg::OnLastfile() 
{
	// TODO: Add your control notification handler code here
	last();
	open(index);
}

void CWinSurgeDlg::OnNextfile() 
{
	// TODO: Add your control notification handler code here
	next();
	open(index);
}

void CWinSurgeDlg::next()
{
	index=index+1;
	if(index>=m_listDlg.m_list.GetCount())
	{
		index=0;
	}
	m_listDlg.m_list.SetCurSel(index);
}

void CWinSurgeDlg::last()
{
	if(index==0)
	{
		index=0;
	}
	else
	{
		index=index-1;
	}
}

void CWinSurgeDlg::OnMin() 
{
	// TODO: Add your control notification handler code here
	//m_listDlg.ShowWindow(SW_HIDE);
	ShowWindow(SW_SHOWMINIMIZED);
	//m_hidef=TRUE;
	//this->m_list.SetPic("face\\"+m_type+"\\buttonbg.bmp",IDB_LIST);
	//m_listDlg.ShowWindow(SW_HIDE);
	NOTIFYICONDATA nid;
	nid.cbSize=sizeof(NOTIFYICONDATA);
	nid.hIcon=m_hIcon;
	nid.hWnd=GetSafeHwnd();
	strcpy(nid.szTip,"欢迎使用WinSurge播放器,双击恢复窗口");
	nid.uCallbackMessage=WM_RESHOW;
	nid.uID=IDR_MAINFRAME;
	nid.uFlags|= NIF_ICON|NIF_MESSAGE|NIF_TIP;
	Shell_NotifyIcon (NIM_ADD,&nid);
	ShowWindow(SW_HIDE);
}

void CWinSurgeDlg::OnClose() 
{
	// TODO: Add your control notification handler code here
	DeleteObject(m_bkBrush);
	OnCancel();
}

void CWinSurgeDlg::OnHelps() 
{
	// TODO: Add your control notification handler code here
	CAboutDlg adlg;
	adlg.DoModal();
	
}

void CWinSurgeDlg::OnDelall() 
{
	// TODO: Add your command handler code here
	m_listDlg.m_list.ResetContent();
	m_mci.MCIClose();
}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CWinSurgeDlg::OnMove(int x, int y) 
{
	CDialog::OnMove(x, y);
	
	// TODO: Add your message handler code here
	RECT rect1;
	GetWindowRect(&rect1);
	m_listDlg.SetWindowPos(NULL,rect1.left,rect1.bottom,0,0,1);
}

void CWinSurgeDlg::OnRButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	nType++;
	if(TypeList[nType]!="")
		m_type=TypeList[nType];
	else
	{
		nType=0;
		m_type=TypeList[nType];
	}
	ChangeFace();
	GetDlgItem(IDC_SLIDER)->Invalidate();
	Invalidate(TRUE);
	CDialog::OnRButtonDblClk(nFlags, point);
}

void CWinSurgeDlg::InitFace()
{
	nType=0;
	for(int i=0;i<MAX_FACE;i++)
	{
		TypeList[i]="";
	}
	char DirName[]="face";
	CFileFind tempFind; 
	char tempFileFind[200];
	memset(tempFileFind,0,200);
	sprintf(tempFileFind,"%s/*.*",DirName); 
	BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind); 
	while(IsFinded)
	{ 
		IsFinded=(BOOL)tempFind.FindNextFile(); 
		if(!tempFind.IsDots()) 
		{ 
			char foundFileName[200];
			memset(foundFileName,0,200);
			strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));
			if(!tempFind.IsDirectory()) 
			{

			}
			else
			{
				CString temp;
				temp=foundFileName;
				TypeList[nType]=temp;
				nType++;
				if(nType==MAX_FACE)
				{
					break;
				}
			}
		}
	}
	tempFind.Close();
	nType=0;
}
void CWinSurgeDlg::OnReShow(WPARAM wParam,LPARAM iParam) 
{
	if (iParam==WM_LBUTTONDBLCLK)
	{
		NOTIFYICONDATA nid;
		nid.cbSize=sizeof(NOTIFYICONDATA);
		nid.hIcon=m_hIcon;
		nid.hWnd=GetSafeHwnd();
		strcpy(nid.szTip,"欢迎使用WinSurge播放器,双击恢复窗口");
		nid.uCallbackMessage=WM_RESHOW;
		nid.uID=IDR_MAINFRAME;
		nid.uFlags|= NIF_MESSAGE|NIF_ICON|NIF_MESSAGE;
		Shell_NotifyIcon (NIM_DELETE,&nid);
		ShowWindow(SW_SHOW);
		BringWindowToTop();
		FlashWindow(TRUE);
	}
}

void CWinSurgeDlg::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	char skin[256];
	memset(skin,0,256);
	char dec[256];
	memset(dec,0,80);
	char szPath[256];
	CUtility::get_moudle_path(szPath,255);
	CString szProfilePath;
	szProfilePath.Format("%s/winsurge.ini",szPath);

	GetPrivateProfileString("Style","Skin","WinXP经典",skin,256,szProfilePath);
	GetPrivateProfileString("Style","PlayDec","",dec,256,szProfilePath);
	CStyleDlg sdlg;
	sdlg.m_dec=dec;
	if(sdlg.DoModal()==IDOK)
	{
		WritePrivateProfileString("Style","PlayDec",sdlg.m_dec,szProfilePath);
		WritePrivateProfileString("Style","Skin",sdlg.m_skin,szProfilePath);
		m_type=sdlg.m_skin;
		ChangeFace();
	}
	CDialog::OnLButtonDblClk(nFlags, point);
}

void CWinSurgeDlg::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	*pResult = 0;
}

void CWinSurgeDlg::ChangeFace()
{
	CStatic* pStatic=(CStatic*)GetDlgItem(IDC_WINTITLE);
	HBITMAP hbm;
	hbm=(HBITMAP)LoadImage(NULL,"face\\"+m_type+"\\title.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
	pStatic->SetBitmap(hbm);
	//
	m_bkBrush.DeleteObject();
	CBitmap m_pDlgBkBmp;
	hbm=(HBITMAP)LoadImage(NULL,"face\\"+m_type+"\\bg.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
	m_pDlgBkBmp.Attach(hbm);
	m_bkBrush.CreatePatternBrush(&m_pDlgBkBmp);
	RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE);

	m_listDlg.ChangeType(m_type);
	m_slide.ChangeType(m_type);

	InitButton("face\\"+m_type+"\\buttonbg.bmp");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -