📄 btnst.h
字号:
/*********************************
* BtnST.H
* By L0op8ack@
*********************************/
#ifndef _BTNST_H
#define _BTNST_H
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define ST_LIKEIE
#define ST_USE_MEMDC
class CButtonST : public CButton //平面按钮
{
public:
CButtonST();
~CButtonST();
enum {ST_ALIGN_HORIZ, ST_ALIGN_VERT};
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CButtonST)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
public:
void AddToolTip ( CString strTip );
BOOL SetBtnCursor(int nCursorId = -1);
void SetFlatFocus(BOOL bDrawFlatFocus, BOOL bRepaint = FALSE);
BOOL GetFlatFocus();
void SetDefaultActiveFgColor(BOOL bRepaint = FALSE);
void SetActiveFgColor(COLORREF crNew, BOOL bRepaint = FALSE);
const COLORREF GetActiveFgColor();
void SetDefaultActiveBgColor(BOOL bRepaint = FALSE);
void SetActiveBgColor(COLORREF crNew, BOOL bRepaint = FALSE);
const COLORREF GetActiveBgColor();
void SetDefaultInactiveFgColor(BOOL bRepaint = FALSE);
void SetInactiveFgColor(COLORREF crNew, BOOL bRepaint = FALSE);
const COLORREF GetInactiveFgColor();
void SetDefaultInactiveBgColor(BOOL bRepaint = FALSE);
void SetInactiveBgColor(COLORREF crNew, BOOL bRepaint = FALSE);
const COLORREF GetInactiveBgColor();
void SetShowText(BOOL bShow = TRUE);
BOOL GetShowText();
void SetAlign(int nAlign);
int GetAlign();
void SetFlat(BOOL bState = TRUE);
BOOL GetFlat();
void DrawBorder(BOOL bEnable = TRUE);
void SetIcon(int nIconInId, int nIconOutId = NULL, BYTE cx = 32, BYTE cy = 32);
static const short GetVersionI();
static const char* GetVersionC();
protected:
CString m_strToolTip;
CToolTipCtrl m_ctrlToolTip;
//{{AFX_MSG(CButtonST)
afx_msg void OnCaptureChanged(CWnd *pWnd);
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
DECLARE_MESSAGE_MAP()
private:
void DrawTheIcon(CDC* pDC, CString* title, RECT* rcItem, CRect* captionRect, BOOL IsPressed, BOOL IsDisabled);
int m_nAlign;
BOOL m_bShowText;
BOOL m_bDrawBorder;
BOOL m_bIsFlat;
BOOL m_MouseOnButton;
BOOL m_bDrawFlatFocus;
HCURSOR m_hCursor;
HICON m_hIconIn;
HICON m_hIconOut;
BYTE m_cyIcon;
BYTE m_cxIcon;
COLORREF m_crInactiveBg;
COLORREF m_crInactiveFg;
COLORREF m_crActiveBg;
COLORREF m_crActiveFg;
};
#ifdef ST_USE_MEMDC
class CMemDC : public CDC
{
public:
CMemDC(CDC* pDC) : CDC()
{
ASSERT(pDC != NULL);
m_pDC = pDC;
m_pOldBitmap = NULL;
m_bMemDC = !pDC->IsPrinting();
if (m_bMemDC)
{
pDC->GetClipBox(&m_rect);
CreateCompatibleDC(pDC);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_bitmap);
SetWindowOrg(m_rect.left, m_rect.top);
}
else
{
m_bPrinting = pDC->m_bPrinting;
m_hDC = pDC->m_hDC;
m_hAttribDC = pDC->m_hAttribDC;
}
}
~CMemDC()
{
if (m_bMemDC)
{
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);
SelectObject(m_pOldBitmap);
} else {
m_hDC = m_hAttribDC = NULL;
}
}
CMemDC* operator->() {return this;}
operator CMemDC*() {return this;}
private:
CBitmap m_bitmap; // Offscreen bitmap
CBitmap* m_pOldBitmap; // bitmap originally found in CMemDC
CDC* m_pDC; // Saves CDC passed in constructor
CRect m_rect; // Rectangle of drawing area.
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
};
#endif
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -