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

📄 barwnd.h

📁 我自己整理的一些VC源代码
💻 H
字号:
#if !defined(AFX_BARWND_H__30EA05E9_F8DE_4A27_9B34_E7EE3DB6778F__INCLUDED_)
#define AFX_BARWND_H__30EA05E9_F8DE_4A27_9B34_E7EE3DB6778F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BarWnd.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CBarWnd window
#define WM_BARWND_NOTIFY	WM_USER + 1
#define WM_BARITEM_LBDOWN	WM_USER + 2
#define WM_BARITEM_RBDOWN	WM_USER + 3
#define WM_BARITEM_LBCLICK	WM_USER + 4

typedef struct tagBarItemMsg{
	int iFolder;
	int iItem;
	CPoint point;
} BarItemMsg;

class CBarWnd : public CWnd
{
// Construction
	DECLARE_DYNCREATE(CBarWnd)
public:
	CBarWnd();

// Attributes
public:
	CFont font;
	CPtrArray arForderbar;
	COLORREF barForecolor;
	COLORREF barTextcolor;
	COLORREF barClientcolor;
	CImageList nrIcon;
	CImageList smallIcon;
	CImageList arrowIcon;

	CPtrArray arSmIcon;
	CPtrArray arNrIcon;
	CPtrArray arArrowIcon;

	int ivstartItem;
	int ivendItem;
	bool uparrow;
	bool downarrow;
	int preindex;
	int preiForder;
	int preiItem;
	bool mouseDown;

	typedef enum{
		normal,
		mouse_on,
		mouse_down,
		redraw
	}DrawStyle;

	typedef enum{
		non,
		pointup,
		pointdown
	}ArrowStyle;

	ArrowStyle arrow;
	ArrowStyle prearrow;

	//	位图数组类
	class CBitmapArray
	{
	public:
		CBitmapArray();
		virtual ~CBitmapArray();
		CBitmap itemBitmap;
		CPtrArray arBitmap;
	};

	//	抽屉框子条件类
	class CBarItem
	{
	public:
		CBarItem(const char * name,int iImage,DWORD ExData=0);
		virtual ~CBarItem(); 
		char * itemName;
		int imageIndex;
		DWORD exData;
	};

	//	抽屉框类
	class CForderBar
	{
	public:
		CForderBar(CString name);
		virtual ~CForderBar();
		void SetForderRect(CRect rect);
		int GetItemCount();
		void AddItem(const char *name,int iImage,DWORD ExData=0);
		bool visible;
		CString nForderName;
		CImageList * smallicon;
		CImageList * nricon;
		CRect nForderRect;
		CPtrArray arItem;
		CWnd * pSon;
	};

// Operations
public:
	void AddForder(LPCTSTR fordername);
	bool AddForderSon(int iForder,CWnd *pSon);
	void GetForderBarRect(int iForder,CRect &rect);
	void GetForderClientRect(int iForder,CRect &rect);
	void GetForderRect(int iForder,CRect &rect);
	void HitOnPos(int cx,int cy,int &index);
	void HitOnPosEx(int cx,int cy,int &index,int &iItem);
	int  GetForderCount();
	void SetForderImageList(int iForder,CImageList * pImage,int iImagesize);
	int  GetForderImageListSize(int iForder);
	void GetForderItemRect(int iForder,int iItem,CRect &rect);
	void GetForderItemActiveRect(int iForder,int iItem,CRect &rcImage,CRect &rcText);
	void AddBitmap(CImageList * pImage,UINT nIDResource);
	void AddIcon(CPtrArray *arIcon,UINT nIDResource);
	void GetArrowRect(int iForder,CRect &rcUp,CRect &rcDown);
	void SelectForderImageStyle(bool nStyle=true);
	void InsertForderItem(int iForder,const char *name,int iImage,DWORD ExData=0);
	void SetForderVisible(int iForder=0);
	int  GetVisibleForderID();
	void GetForderItemText(int iForder,int iItem,CString &str);
	void AutoAddItemFromFileini(LPCTSTR lpKeyName,LPCTSTR fileini);
	int  GetForderItemCount(int iForder);
	bool NewItem();

protected:
	void DrawItem(int iForder,int iItem,CDC *pDC,DrawStyle nStyle=redraw);
	void DrawForderItem(int iForder,CDC *pDC);
	void DrawForder(int iForder,CDC *pDC, const bool bSelected);
	void DrawArrow(int iForder,CDC * pDC,DrawStyle nStyle=redraw);
	void OnUpArrow(int iForder);
	void OnDownArrow(int iForder);
	void OnItem(int iForder,int iItem,CPoint point);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CBarWnd)
	public:
	virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
	protected:
	virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL

// Implementation
public:
	DWORD GetItemData( int iFolder, int iItem );
	virtual ~CBarWnd();

	// Generated message map functions
protected:
	//{{AFX_MSG(CBarWnd)
	afx_msg void OnHaveFlash();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();
	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 void OnTimer(UINT nIDEvent);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnSmall();
	afx_msg void OnBig();
	afx_msg void OnDestroy();
	afx_msg void OnDoInsert();
	afx_msg bool OnInsertItem();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_BARWND_H__30EA05E9_F8DE_4A27_9B34_E7EE3DB6778F__INCLUDED_)

⌨️ 快捷键说明

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