📄 btnst.h
字号:
#ifndef _BTNST_H
#define _BTNST_H
#define BTNST_USE_BCMENU
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef BTNST_OK
#define BTNST_OK 0
#endif
#ifndef BTNST_INVALIDRESOURCE
#define BTNST_INVALIDRESOURCE 1
#endif
#ifndef BTNST_FAILEDMASK
#define BTNST_FAILEDMASK 2
#endif
#ifndef BTNST_INVALIDINDEX
#define BTNST_INVALIDINDEX 3
#endif
#ifndef BTNST_INVALIDALIGN
#define BTNST_INVALIDALIGN 4
#endif
#ifndef BTNST_BADPARAM
#define BTNST_BADPARAM 5
#endif
#ifndef BTNST_AUTO_GRAY
#define BTNST_AUTO_GRAY (HICON)(0xffffffff - 1L)
#endif
class AFX_EXT_CLASS CButtonST : public CButton
{
public:
CButtonST();
~CButtonST();
enum { ST_ALIGN_HORIZ = 0,
ST_ALIGN_VERT,
ST_ALIGN_HORIZ_RIGHT
};
enum { BTNST_COLOR_BK_IN = 0,
BTNST_COLOR_FG_IN,
BTNST_COLOR_BK_OUT,
BTNST_COLOR_FG_OUT,
BTNST_COLOR_BK_FOCUS,
BTNST_COLOR_FG_FOCUS,
BTNST_MAX_COLORS
};
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CButtonST)
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
public:
DWORD SetDefaultColors(BOOL bRepaint = TRUE);
DWORD SetColor(BYTE byColorIndex, COLORREF crColor, BOOL bRepaint = TRUE);
DWORD GetColor(BYTE byColorIndex, COLORREF* crpColor);
DWORD OffsetColor(BYTE byColorIndex, short shOffset, BOOL bRepaint = TRUE);
DWORD SetCheck(int nCheck, BOOL bRepaint = TRUE);
int GetCheck();
DWORD SetURL(LPCTSTR lpszURL = NULL);
void DrawTransparent(BOOL bRepaint = FALSE);
BOOL GetDefault();
DWORD SetAlwaysTrack(BOOL bAlwaysTrack = TRUE);
void SetTooltipText(int nText, BOOL bActivate = TRUE);
void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE);
void ActivateTooltip(BOOL bEnable = TRUE);
DWORD SetBtnCursor(int nCursorId = NULL, BOOL bRepaint = TRUE);
DWORD SetFlat(BOOL bFlat = TRUE, BOOL bRepaint = TRUE);
DWORD SetAlign(BYTE byAlign, BOOL bRepaint = TRUE);
DWORD DrawBorder(BOOL bDrawBorder = TRUE, BOOL bRepaint = TRUE);
DWORD DrawFlatFocus(BOOL bDrawFlatFocus, BOOL bRepaint = TRUE);
DWORD SetIcon(int nIconIn, int nIconOut = NULL);
DWORD SetIcon(HICON hIconIn, HICON hIconOut = NULL);
DWORD SetBitmaps(int nBitmapIn, COLORREF crTransColorIn, int nBitmapOut = NULL, COLORREF crTransColorOut = 0);
DWORD SetBitmaps(HBITMAP hBitmapIn, COLORREF crTransColorIn, HBITMAP hBitmapOut = NULL, COLORREF crTransColorOut = 0);
void SetShowText(BOOL bShow = FALSE);
static short GetVersionI() {return 35;}
static LPCTSTR GetVersionC() {return (LPCTSTR)_T("3.5");}
BOOL m_bShowDisabledBitmap;
protected:
//{{AFX_MSG(CButtonST)
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSysColorChange();
afx_msg BOOL OnClicked();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnEnable(BOOL bEnable);
afx_msg void OnCancelMode();
afx_msg UINT OnGetDlgCode();
//}}AFX_MSG
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
//----------------------------------------------------------------------------------------------
HICON CreateGrayscaleIcon(HICON hIcon);
virtual DWORD OnDrawBackground(CDC* pDC, LPCRECT pRect);
virtual DWORD OnDrawBorder(CDC* pDC, LPCRECT pRect);
BOOL m_bIsFlat;
BOOL m_bMouseOnButton;
BOOL m_bDrawTransparent;
BOOL m_bIsPressed;
BOOL m_bIsFocused;
BOOL m_bIsDisabled;
BOOL m_bIsDefault;
BOOL m_bIsCheckBox;
BYTE m_byAlign;
BOOL m_bDrawBorder;
BOOL m_bDrawFlatFocus;
COLORREF m_crColors[BTNST_MAX_COLORS];
BOOL m_bShowText;
private:
LRESULT OnSetCheck(WPARAM wParam, LPARAM lParam);
LRESULT OnGetCheck(WPARAM wParam, LPARAM lParam);
LRESULT OnSetStyle(WPARAM wParam, LPARAM lParam);
LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
void CancelHover();
void FreeResources(BOOL bCheckForNULL = TRUE);
void PrepareImageRect(BOOL bHasTitle, RECT* rpItem, CRect* rpTitle, BOOL bIsPressed, DWORD dwWidth, DWORD dwHeight, CRect* rpImage);
HBITMAP CreateBitmapMask(HBITMAP hSourceBitmap, DWORD dwWidth, DWORD dwHeight, COLORREF crTransColor);
void DrawTheIcon(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpTitle, BOOL bIsPressed, BOOL bIsDisabled);
void DrawTheBitmap(CDC* pDC, BOOL bHasTitle, RECT *rItem, CRect *rCaption, BOOL bIsPressed, BOOL bIsDisabled);
void PaintBk(CDC* pDC);
void InitToolTip();
HCURSOR m_hCursor;
CToolTipCtrl m_ToolTip;
CDC m_dcBk;
CBitmap m_bmpBk;
CBitmap* m_pbmpOldBk;
BOOL m_bAlwaysTrack;
int m_nCheck;
UINT m_nTypeStyle;
TCHAR m_szURL[_MAX_PATH];
#pragma pack(1)
typedef struct _STRUCT_ICONS
{
HICON hIcon;
DWORD dwWidth;
DWORD dwHeight;
} STRUCT_ICONS;
#pragma pack()
#pragma pack(1)
typedef struct _STRUCT_BITMAPS
{
HBITMAP hBitmap;
DWORD dwWidth;
DWORD dwHeight;
HBITMAP hMask;
COLORREF crTransparent;
} STRUCT_BITMAPS;
#pragma pack()
STRUCT_ICONS m_csIcons[2];
STRUCT_BITMAPS m_csBitmaps[2];
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -