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

📄 mp3listbox.h

📁 一些关于C++开发的多媒体制作书籍的源代码
💻 H
字号:
/*
* Copyright (c) 2002, Bcdliang
* All rights reserved.
*
* 文件名称:CMP3ListBox.h
* 摘    要:类CMP3ListBox的声明
            类CMP3ListBox派生于CListBox,乃自画控件,有三“列”(分别存于类CMP3ListBoxItem中):
				其一为m_Path——MP3文件路径;
				其二为m_Title——MP3文件信息,其格式为
					作者 - 歌名
				其三为m_Length——MP3文件长度,其格式为
					00:00
			自画时条目将显示为
			      3.作者 - 歌名                     00:00
			当Title或Length太长而不能全显示时将显示为
			      3.作者 - 歌名太长了了了了了...  100:...
            ListBox的Style必须为Owner-draw fixed, NOT Has string
*
* 当前版本:1.01
* 作    者:LIANG Zheng
* 完成日期:2002年8月11日
*/

#if !defined(AFX_MP3LISTBOX_H__AB77E042_59C0_4470_A2E0_6839A0299AFC__INCLUDED_)
#define AFX_MP3LISTBOX_H__AB77E042_59C0_4470_A2E0_6839A0299AFC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ID3TAG.H"

// 列表项类
class CMP3ListBoxItem
{
public:
	CString m_Path;		// MP3文件路径
	CString m_Title;	// MP3文件信息
	CString m_Length;	// MP3文件长度
};

/////////////////////////////////////////////////////////////////////////////
// CMP3ListBox window

class CMP3ListBox : public CListBox
{
// Construction
public:
	CMP3ListBox();

// Attributes
public:
	// Width of Title column & Length column
	enum { MLB_TITLE_WIDTH = 198, MLB_LENGTH_WIDTH = 50 };

	// Brush for background painting

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMP3ListBox)
	public:
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
private:
	// 将添加/删除列表项的成员函数全改为私有
	int AddString(LPCTSTR lpszItem);
	int DeleteString(UINT nIndex);
	void ResetContent();
	int InsertString( int nIndex, LPCTSTR lpszItem );
	int Dir( UINT attr, LPCTSTR lpszWildCard );

public:
	int AddFile(const CString &strPath);
	int DeleteFile(UINT nIndex);
	int DeleteSelectedFiles();
	void DeleteAllFiles();
	void AddDir(LPVOID lpvoid);
	int OpenM3U(const CString &strPath);
	int SaveM3U(const CString &strPath);
	void UpdateSongInfo(UINT uItemID);

// Get/Set	
	void SetTitle(UINT uItemID, const CString &strNewTitle);
	CString GetTitle(UINT uItemID) const;
	CString GetRawTitle(UINT uItemID) const;
	void SetLength(UINT uItemID, const CString &strNewLength);
	CString GetLength(UINT uItemID) const;
	CString GetRawLength(UINT uItemID) const;
	CString GetPath(UINT uItemID) const;

	void SetHotItem(UINT uHotItemID);
	UINT GetHotItem() const;

	void SetBkColor(COLORREF crColor);
	COLORREF GetBkColor() const;
	void SetSelectedBkColor(COLORREF crColor);
	COLORREF GetSelectedBkColor() const;
	void SetHotBkColor(COLORREF crColor);
	COLORREF GetHotBkColor() const;
	void SetTextColor(COLORREF crColor);
	COLORREF GetTextColor() const;
	void SetSelectedTextColor(COLORREF crColor);
	COLORREF GetSelectedTextColor() const;
	void SetHotTextColor(COLORREF crColor);
	COLORREF GetHotTextColor() const;

	virtual ~CMP3ListBox();

	// Generated message map functions
protected:
	HACCEL m_hAccTable;		//加速键表
	// whether the Initialize() member has been call
//	BOOL m_bInitialized;
	int m_iHotItemID;
	CMP3ListBoxItem * m_pItem;

	// String array to store Path, Title & Length
//	CStringArray m_saPath;
//	CStringArray m_saTitle;
//	CStringArray m_saLength;

	// Member for id3tag accessing
	CID3TAG m_id3tag;

	// Draw area of items
	CRect m_rTitle;
	CRect m_rLength;

	// Colors for DrawItem
	COLORREF m_crNormalBk, m_crNormalText;
	COLORREF m_crSelectedBk, m_crSelectedText;
	COLORREF m_crHotBk, m_crHotText;

	// Bk brush
	HBRUSH m_hBrush;

	// 拖动列表项所需的成员变量
	// 是否正在进行拖动操作,用于在鼠标事件中指示状态
	BOOL m_bDragging;
	// 当前项的index,随列表项的移动,其值会改变
	int m_nCurrentItem;
	// 选定项数目
	int m_nSelCount;
	// 指向动态申请的空间,该空间用于存储选定项的index
	int *m_pSelItems;
	// 指向动态申请的空间,该空间用于存储选定项的值(即指向项目信息结构CMP3ListBoxItem的指针)
	CMP3ListBoxItem **m_pSelValues;
	// 鼠标是否被按下
	BOOL m_bMouseDown;
	// 鼠标按下时所指向的Item的矩形区域
	CRect m_rItem;
	
	//{{AFX_MSG(CMP3ListBox)
	afx_msg void OnContextMenu(CWnd*, CPoint point);
	afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
	afx_msg void OnListmenuDelete();
	afx_msg void OnListmenuInfo();
	afx_msg void OnListmenuPlay();
	afx_msg void OnDblclk();
	afx_msg void OnDestroy();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MP3LISTBOX_H__AB77E042_59C0_4470_A2E0_6839A0299AFC__INCLUDED_)


⌨️ 快捷键说明

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