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

📄 mybutton.h

📁 自己手动做按钮代码和详细步骤
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////
//CMyButton:圆角矩形按钮
//
//用法:
//①在对话框中放置一个按钮控件;
//②为按钮定义变量,类型改为CMyButton;
//③若想重设按钮文本颜色和背景颜色,在对话框的OnInitDialog()函数中设置。
//
//作者:风林
//                   2004-12-18
////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYBUTTON_H__351CBBC5_8129_404E_BDDD_F0C29D05104F__INCLUDED_)
#define AFX_MYBUTTON_H__351CBBC5_8129_404E_BDDD_F0C29D05104F__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CMyButton window

class CMyButton : public CButton
{
// Construction
public:
	CMyButton();

private:
	BOOL    b_Flag;			//按钮状态(false-正常,true-当前)
	BOOL    b_InRect;		//鼠标进入标志
	CString m_strText;		//按钮文字
	COLORREF m_ForeColor;	//文本颜色
	COLORREF m_BkColor;		//背景色
	COLORREF m_LockForeColor;	//锁定按钮的文字颜色
	CRect   m_ButRect;		//按钮尺寸
	CPoint  m_textPt;		//文字坐标(左上角)

	void   NormalButton(CDC *pDC);		//画正常的按钮
	void   PassButton(CDC *pDC);		//画鼠标经过时的按钮
	void   LockButton(CDC *pDC);		//画锁定的按钮

// Attributes
public:
	void  SetForeColor(COLORREF color);	//设置文本颜色
	void  SetBkColor(COLORREF color);	//设置背景颜色

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMyButton)
	public:
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	protected:
	virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMyButton();

	// Generated message map functions
protected:
	//{{AFX_MSG(CMyButton)
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_MYBUTTON_H__351CBBC5_8129_404E_BDDD_F0C29D05104F__INCLUDED_)

⌨️ 快捷键说明

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