📄 flatbutton.h
字号:
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by Yuheng Zhao
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// If you have any questions, I can be reached as follows:
// yuheng@ministars.com
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _FLATBUTTON_H_
#define _FLATBUTTON_H_
#define WM_FB_NOTIFY WM_USER + 33
#define FB_NOTIFY_INITMENU 1
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CFlatButton : public CButton
{
HICON m_hIcon;
BYTE m_nIconWidth, m_nIconHeight;
DWORD dwFlags;
BOOL m_bMouseIn;
BOOL m_bChecked;
//To display Menu
CMenu* m_pMenu;
BOOL m_bClickAgain; // To determine if the user has clicked the button again, then close menu
void DoMenu();
//Tooltip
CToolTipCtrl m_ToolTip;
private:
void DrawArrow(CDC* pDC, const CPoint& ptTopLeft, int nWidth, DWORD dwType);
// Construction
public:
CFlatButton();
// Attributes
public:
// FBS_XXXXX FlatButtonStyle_XXXXXX
enum {
FBS_BORDER = 1 << 0,
FBS_FOCUS = 1 << 1,
FBS_ARROW_UP = 1 << 2,
FBS_ARROW_DOWN = 1 << 3,
FBS_CHECKED_NOBORDER = 1 << 4,
FBS_HAS_ICON = 1 << 5,
FBS_MENU_BUTTON = 1 << 6,
FBS_MENU_ALIGN_RIGHT = 1 << 7, // left by default
FBS_MENU_ALIGN_TOP = 1 << 8, // Bottom by default
FBS_ROLLOVER = 1 << 9, // If make 3d when mouse is in
};
// Operations
public:
void SetIcon(HICON hIcon, BYTE cx, BYTE cy);
void SetMenu(CMenu* pMenu) {m_pMenu = pMenu;}
void SetCheck(BOOL b);
BOOL GetCheck();
void SetTooltipText(int nId, BOOL bActivate = TRUE);
void SetTooltipText(LPCTSTR strTooltip, BOOL bActivate = TRUE);
void EnableTooltip(BOOL bEnable = TRUE);
void ModifyFlag(const DWORD &dwRemove, const DWORD &dwAdd, const UINT bRedraw = 0);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFlatButton)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void PreSubclassWindow();
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
//CRect rect;
virtual ~CFlatButton();
// Generated message map functions
protected:
//{{AFX_MSG(CFlatButton)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
//}}AFX_MSG
afx_msg void OnTimer(UINT nIDEvent);
DECLARE_MESSAGE_MAP()
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -