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

📄 label.h

📁 visual c++ 实例编程
💻 H
字号:
/**
 * 此文件从CLabel修改得来
 *
 * thinkry@263.net  2003-08-15
 **/

#if !defined(AFX_XLABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
#define AFX_XLABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_

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

#define	NM_LINKCLICK	WM_APP + 0x200

/////////////////////////////////////////////////////////////////////////////
// CXLabel window

class CXLabel : public CStatic
{
// Construction
public:


	static enum LinkStyle { LinkNone, HyperLink, MailLink };
	static enum FlashType {None, Text, Background };
	static enum Type3D { Raised, Sunken};
	static enum BackFillMode { Normal, Gradient };

	CXLabel();
	virtual CXLabel& SetBkColor(COLORREF crBkgnd, COLORREF crBkgndHigh = 0, BackFillMode mode = Normal);
	virtual CXLabel& SetTextColor(COLORREF crText);
	virtual CXLabel& SetText(const CString& strText);
	virtual CXLabel& SetFontBold(BOOL bBold);
	virtual CXLabel& SetFontName(const CString& strFont, BYTE byCharSet = ANSI_CHARSET);
	virtual CXLabel& SetFontUnderline(BOOL bSet);
	virtual CXLabel& SetFontItalic(BOOL bSet);
	virtual CXLabel& SetFontSize(int nSize);
	virtual CXLabel& SetSunken(BOOL bSet);
	virtual CXLabel& SetBorder(BOOL bSet);
	virtual CXLabel& SetTransparent(BOOL bSet);
	virtual CXLabel& FlashText(BOOL bActivate);
	virtual CXLabel& FlashBackground(BOOL bActivate);
	virtual CXLabel& SetLink(BOOL bLink,BOOL bNotifyParent);
	virtual CXLabel& SetLinkCursor(HCURSOR hCursor);
	virtual CXLabel& SetFont3D(BOOL bSet,Type3D type=Raised);
	virtual CXLabel& SetRotationAngle(UINT nAngle,BOOL bRotation);
	virtual CXLabel& SetText3DHiliteColor(COLORREF cr3DHiliteColor);
	virtual CXLabel& SetFont(LOGFONT lf);
	virtual CXLabel& SetMailLink(BOOL bEnable, BOOL bNotifyParent);
	virtual CXLabel& SetHyperLink(const CString& sLink);

// Attributes
public:
protected:
	void UpdateSurface();
	void ReconstructFont();
	void DrawGradientFill(CDC* pDC, CRect* pRect, COLORREF crStart, COLORREF crEnd, int nSegments);
	COLORREF		m_crText;
	COLORREF		m_cr3DHiliteColor;
	HBRUSH			m_hwndBrush;
	HBRUSH			m_hBackBrush;
	LOGFONT			m_lf;
	CFont			m_font;
	BOOL			m_bState;
	BOOL			m_bTimer;
	LinkStyle		m_Link;
	BOOL			m_bTransparent;
	BOOL			m_bFont3d;
	BOOL			m_bToolTips;
	BOOL			m_bNotifyParent;
	BOOL			m_bRotation;
	FlashType		m_Type;
	HCURSOR			m_hCursor;
	Type3D			m_3dType;
	BackFillMode	m_fillmode;
	COLORREF		m_crHiColor;
	COLORREF		m_crLoColor;
	CString			m_sLink;

	//add by thinkry
	void PositionWindow();

	// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CXLabel)
	protected:
	virtual void PreSubclassWindow();
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
public:
	//add by thinkry

	BOOL  GetAutoSize() const { return m_bAdjustToFit;} ;
	void  SetAutoSize(BOOL bAutoSize=TRUE);
	void  SetHandCursor();
	void  SetCommand(DWORD comm, COLORREF color=RGB(0,0,255));
	DWORD GetCommand() const {	return m_dwCommand;} ;
	
	virtual ~CXLabel();

	// Generated message map functions
protected:
	DWORD m_dwCommand;
	BOOL m_bAdjustToFit;
	//{{AFX_MSG(CXLabel)
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnSysColorChange();
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

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

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_XLABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)

⌨️ 快捷键说明

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