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

📄 winsurgedlg.cpp

📁 winsur 源码 winsur 源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// WinSurgeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "WinSurge.h"
#include "WinSurgeDlg.h"
#include "StyleDlg.h"
#include "../utility/utility.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define LOGOSTR "无限精彩,尽在洋溢"
#define WM_RESHOW WM_USER+101

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	CBrush m_bkBrush;
	//{{AFX_MSG(CAboutDlg)
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
	CBitmap m_pDlgBkBmp;
	m_pDlgBkBmp.LoadBitmap(IDB_HELPB);
	m_bkBrush.CreatePatternBrush(&m_pDlgBkBmp);
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_WM_CTLCOLOR()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWinSurgeDlg dialog

CWinSurgeDlg::CWinSurgeDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CWinSurgeDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CWinSurgeDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	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);

	InitFace();
	nType=0;
	m_type=skin;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	CBitmap m_pDlgBkBmp;
	//m_pDlgBkBmp.LoadBitmap(DIALOG_BKCOLOR);
	HBITMAP hbm;
	hbm=(HBITMAP)LoadImage(NULL,"face\\"+m_type+"\\bg.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
	m_pDlgBkBmp.Attach(hbm);
	m_bkBrush.CreatePatternBrush(&m_pDlgBkBmp);
	m_listDlg.Create(IDD_LIST_DIALOG,this);
}

void CWinSurgeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CWinSurgeDlg)
	DDX_Control(pDX, IDC_SLIDER, m_slide);
	DDX_Control(pDX, IDC_HELPS, m_helpB);
	DDX_Control(pDX, IDC_LASTSTEP, m_lasts);
	DDX_Control(pDX, IDC_LASTFILE, m_lastf);
	DDX_Control(pDX, IDC_LIST, m_list);
	DDX_Control(pDX, IDC_STOP, m_stop);
	DDX_Control(pDX, IDC_PLAY, m_play);
	DDX_Control(pDX, IDC_PAUSE, m_pause);
	DDX_Control(pDX, IDC_NEXTSTEP, m_nexts);
	DDX_Control(pDX, IDC_NEXTFILE, m_nextf);
	DDX_Control(pDX, IDC_LOOP, m_loop);
	DDX_Control(pDX, IDC_ADDFILE, m_addf);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CWinSurgeDlg, CDialog)
	//{{AFX_MSG_MAP(CWinSurgeDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_TIMER()
	ON_WM_LBUTTONDOWN()
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_ADDFILE, OnAddfile)
	ON_BN_CLICKED(IDC_PLAY, OnPlay)
	ON_BN_CLICKED(IDC_PAUSE, OnPause)
	ON_BN_CLICKED(IDC_STOP, OnStop)
	ON_BN_CLICKED(IDC_LASTSTEP, OnLaststep)
	ON_BN_CLICKED(IDC_NEXTSTEP, OnNextstep)
	ON_BN_CLICKED(IDC_LOOP, OnLoop)
	ON_WM_HSCROLL()
	ON_BN_CLICKED(IDC_LIST, OnList)
	ON_COMMAND(IDM_ADDSINGLE, OnAddsingle)
	ON_COMMAND(IDM_ADDGROUP, OnAddgroup)
	ON_BN_CLICKED(IDC_LASTFILE, OnLastfile)
	ON_BN_CLICKED(IDC_NEXTFILE, OnNextfile)
	ON_BN_CLICKED(IDB_MIN, OnMin)
	ON_BN_CLICKED(IDC_CLOSE, OnClose)
	ON_BN_CLICKED(IDC_HELPS, OnHelps)
	ON_COMMAND(IDM_DELALL, OnDelall)
	ON_WM_MOVE()
	ON_WM_RBUTTONDBLCLK()
	ON_WM_LBUTTONDBLCLK()
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER, OnCustomdrawSlider)
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_RESHOW, OnReShow)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWinSurgeDlg message handlers

BOOL CWinSurgeDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	// TODO: Add extra initialization here
	m_loopf=FALSE;
	m_hidef=TRUE;
	SetWindowText("洋溢音频播放器");
	pWnd=GetDlgItem(IDC_TITLE);
	pDC=pWnd->GetDC();
	pWnd->GetClientRect(&rect);
	pDC->Rectangle(&rect);
	x=0;
	y=5;
	DiStr=LOGOSTR;
	TimeStr="作者:大笨猫";
	SetTimer(0,15,NULL);
	UpdateData(FALSE);
	// CG: The following block was added by the ToolTips component.	{		// Create the ToolTip control.
		m_tooltip.Create(this,TTS_ALWAYSTIP);
		m_tooltip.Activate(TRUE);		// TODO: Use one of the following forms to add controls:		// m_tooltip.AddTool(GetDlgItem(IDC_<name>), <string-table-id>);		// m_tooltip.AddTool(GetDlgItem(IDC_<name>), "<text>");	}
	InitButton("face\\"+m_type+"\\buttonbg.bmp");
	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_slide.m_type=m_type;
	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","PlayDec","",dec,256,szProfilePath);
	if(strcmp(dec,""))
	{
		FindFiles(dec);
		index=0;
		open(index);
	}
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CWinSurgeDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CWinSurgeDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CWinSurgeDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CWinSurgeDlg::DrawBmp(int x, int y, CString key, int i)
{
	if(i==0)
	{
		CDC pDCb;
		pDCb.CreateCompatibleDC(pDC);
		CBitmap bitmap;
		HBITMAP hbm;
		hbm=(HBITMAP)LoadImage(NULL,"face\\"+m_type+"\\screen.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
		bitmap.Attach(hbm);
		pDCb.SelectObject(&bitmap);
		CFont* m_font=GetFont();;
		CFont* oFont=pDCb.SelectObject(m_font);
		pDCb.SetBkMode(TRANSPARENT);
		pDCb.SetTextColor(RGB(0,0,100));
		pDCb.TextOut(x,y,key);
		pDCb.TextOut(70,40,TimeStr);
		pDCb.TextOut(180,40,m_type);
		if(m_mci.MCIIsPlaying()==TRUE)
		{
			CPen penL(PS_SOLID,3,RGB(100,0,255));
			CPen* oPen=pDCb.SelectObject(&penL);
			int i;
			i=rand()%30;
			pDCb.MoveTo(10,50);
			pDCb.LineTo(10,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(15,50);
			pDCb.LineTo(15,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(20,50);
			pDCb.LineTo(20,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(25,50);
			pDCb.LineTo(25,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(30,50);
			pDCb.LineTo(30,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(35,50);
			pDCb.LineTo(35,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(40,50);
			pDCb.LineTo(40,50-i);
			
			i=rand()%30;
			pDCb.MoveTo(45,50);
			pDCb.LineTo(45,50-i);
		}
		pDCb.SelectObject(oFont);
		pDC->BitBlt(0,0,rect.Width(),rect.Height(),&pDCb,0,0,SRCCOPY);
		pDCb.DeleteDC();
		bitmap.DeleteObject();
	}
}

void CWinSurgeDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	DrawBmp(x++,y,DiStr,0);
	if(x>=rect.Width())
	{
		x=0;
	}
	if(m_mci.MCIIsPlaying()==TRUE)
	{
		DWORD dwp;
		DWORD dwl;
		m_mci.MCIGetLength(&dwl);
		m_mci.MCIGetPos(&dwp);

		DWORD dwPos;
		m_mci.MCIGetPos(&dwPos);
		dwPos=m_mci.m_dwLength-dwPos;
		CString strLength;
		strLength.Format("剩余时间:%d:%02d", dwPos/60, dwPos%60);
		TimeStr=strLength;
		
		if(dwp>=dwl)
		{
			m_slide.SetPos(0);
			m_mci.MCISeekToStart();
			if(m_loopf==TRUE)
			{
				m_mci.MCIPlay();
			}
			else
			{
				next();
				open(index);
			}
		}
		else
		{
			
			DWORD dwPos;
			m_mci.MCIGetPos(&dwPos);
			m_slide.SetPos(((int)dwPos));
		}
	}
	CDialog::OnTimer(nIDEvent);
}

void CWinSurgeDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM (point.x , point.y));
	RECT rect1;
	GetWindowRect(&rect1);
	m_listDlg.SetWindowPos(NULL,rect1.left,rect1.bottom,0,0,1);
	CDialog::OnLButtonDown(nFlags, point);
}

HBRUSH CWinSurgeDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	if (nCtlColor!= CTLCOLOR_SCROLLBAR)
		return  (HBRUSH)m_bkBrush.GetSafeHandle();
	else
		return hbr;
	
}

void CWinSurgeDlg::OnAddfile() 
{
	// TODO: Add your control notification handler code here
	RECT rect2;
	m_addf.GetWindowRect(&rect2);
	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_MENU));    
	// popup View alternative
	DWORD pos=GetMessagePos();
	POINTS point;
	point=MAKEPOINTS(pos);
	CMenu* pPopup;
	pPopup=menu.GetSubMenu(0);
	pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,rect2.left,rect2.bottom,this);
	
}

void CWinSurgeDlg::OnPlay() 
{
	// TODO: Add your control notification handler code here
	Play();
}

void CWinSurgeDlg::OnPause() 
{
	// TODO: Add your control notification handler code here
	Pause();
}

void CWinSurgeDlg::OnStop() 
{
	// TODO: Add your control notification handler code here
	Stop();
	//Invalidate();
}

void CWinSurgeDlg::InitButton(CString path)
{
	/*
	this->m_addf.SetPic(path,IDB_OPENF);
	this->m_loop.SetPic(path,IDB_GOON);
	this->m_nextf.SetPic(path,IDB_LAST);
	this->m_nexts.SetPic(path,IDB_STEP);
	this->m_pause.SetPic(path,IDB_PAUSE);
	this->m_play.SetPic(path,IDB_PLAY);
	this->m_stop.SetPic(path,IDB_STOP);
	this->m_list.SetPic(path,IDB_LIST);
	this->m_lastf.SetPic(path,IDB_NEXT);
	this->m_lasts.SetPic(path,IDB_LASTSTEP);
	*/

⌨️ 快捷键说明

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