Click here to Skip to main content
15,894,825 members
Articles / Desktop Programming / MFC

XButtonXP - an XP-aware pushbutton that can also toggle and display an icon

Rate me:
Please Sign up or sign in to vote.
4.89/5 (49 votes)
19 Jan 2008CPOL6 min read 540.5K   6.3K   145  
XButtonXP is an XP theme-aware pushbutton that can optionally be used as a toggle button. It can also display an icon with or without text.
// XButtonXPTestDlg.h : header file
//

#ifndef  XBUTTONXPTESTDLG_H 
#define  XBUTTONXPTESTDLG_H 

#include "XButtonXP.h"

/////////////////////////////////////////////////////////////////////////////
// CXButtonXPTestDlg dialog

class CXButtonXPTestDlg : public CDialog
{
// Construction
public:
	CXButtonXPTestDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CXButtonXPTestDlg)
	enum { IDD = IDD_XBUTTONXPTEST_DIALOG };
	CComboBox	m_comboIcon;
	CButton		m_chkToolbar;
	CButton		m_chkTheme;
	CButton		m_chkToggle;
	CEdit		m_edtCount2;
	CEdit		m_edtCount1;
	CXButtonXP	m_XButtonXP;
	int			m_nIcon;
	BOOL		m_bTheme;
	BOOL		m_bMultiLine;
	BOOL		m_bDisabled;
	BOOL		m_bDefault;
	BOOL		m_bMessageBox;
	BOOL		m_bPattern;
	int			m_nIconIndex;
	BOOL		m_bToolbar;
	BOOL		m_bToggle;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CXButtonXPTestDlg)
public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;
	CBrush m_brush;
	CString m_strButton2Title;
	CToolTipCtrl m_ToolTips;
	UINT m_nIconId;

	int GetIconIndex();

	// Generated message map functions
	//{{AFX_MSG(CXButtonXPTestDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButton1();
	afx_msg void OnButton2();
	afx_msg void OnIconLeft();
	afx_msg void OnIconNo();
	afx_msg void OnIconRight();
	afx_msg void OnToggle();
	afx_msg void OnTextNo();
	afx_msg void OnTheme();
	afx_msg void OnToolbar();
	afx_msg void OnDisabled();
	afx_msg void OnMultiline();
	afx_msg void OnDefault();
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPattern();
	afx_msg void OnSelendokIconCombo();
	afx_msg void OnOnlineHelp();
	afx_msg void OnColors();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

#endif // XBUTTONXPTESTDLG_H 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Hans Dietrich Software
United States United States
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.

Recently, I have moved to Los Angeles where I am doing consulting and development work.

For consulting and custom software development, please see www.hdsoft.org.






Comments and Discussions