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

📄 buttonst.h

📁 一个好玩的俄罗斯方块游戏
💻 H
字号:
#ifndef _BUTTONST_H
#define _BUTTONST_H
//#if !defined(AFX_BTNST_H__54BEB054_145A_4DCD_B52A_1E2B86BC03B3__INCLUDED_)
//#define AFX_BTNST_H__54BEB054_145A_4DCD_B52A_1E2B86BC03B3__INCLUDED_

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

#define ST_LIKEIE
#define ST_USE_MEMDC
/////////////////////////////////////////////////////////////////////////////
// CButtonST window

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

	enum {ST_ALIGN_HORIZ, ST_ALIGN_VERT};


// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CButtonST)
	protected:
	virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL

// Implementation
public:
	void SetIcon(int nIconInId,int nIconOutId=NULL,BYTE cx=32,BYTE cy=32);
	void SetShowText(BOOL bShow=TRUE);
	void SetInactiveFgColor(COLORREF crNew,BOOL bRepaint=FALSE);
	void SetInactiveBgColor(COLORREF crNew,BOOL bRepaint=FALSE);
	void SetFlatFocus(BOOL bDrawFlatFocus,BOOL bRepaint=FALSE);
	void SetFlat(BOOL bState=TRUE);
	void SetDefaultInactiveFgColor(BOOL bRepaint=FALSE);
	void SetDefaultInactiveBgColor(BOOL bRepaint=FALSE);
	void SetDefaultActiveFgColor(BOOL bRepaint=FALSE);
	void SetDefaultActiveBgColor(BOOL bRepaint=FALSE);
	BOOL SetBtnCursor(int nCursorId=-1);
	void SetAlign(int nAlign);
	void SetActiveFgColor(COLORREF crNew,BOOL bRepaint=FALSE);
	void SetActiveBgColor(COLORREF crNew,BOOL bRepaint=FALSE);
	const short GetVersionI();
	const char * GetVersionC();
	const COLORREF GetInactiveFgColor();
	const COLORREF GetInactiveBgColor();
	BOOL GetFlatFocus();
	const COLORREF GetActiveFgColor();
	const COLORREF GetActiveBgColor();
	BOOL GetFlat();
	int GetAlign();
	BOOL GetShowText();
	void DrawItem(LPDRAWITEMSTRUCT lpDIS);
	void DrawBorder(BOOL bEnable);
	void AddToolTip(const CString &strTip);
	virtual ~CButtonST();

	// Generated message map functions
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 OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
private:
	int m_nAlign;
	BOOL m_MouseOnButton;
	HCURSOR m_hCursor;
	BYTE m_cxIcon;
	BYTE m_cyIcon;
	HICON m_hIconOut;
	HICON m_hIconIn;
	COLORREF m_crActiveFg;
	COLORREF m_crActiveBg;
	COLORREF m_crInactiveFg;
	COLORREF m_crInactiveBg;
	BOOL m_bShowText;
	BOOL m_bIsFlat;
	BOOL m_bDrawFlatFocus;
	BOOL m_bDrawBorder;
	void DrawTheIcon(CDC* pDC,CString * title,RECT* rcItem,CRect * captionRect,BOOL IsPressed, BOOL IsDisabled);
};


#ifdef ST_USE_MEMDC

class CMemDC : public CDC
{
public:

    // constructor sets up the memory DC
    CMemDC(CDC* pDC) : CDC()
    {
        ASSERT(pDC != NULL);

        m_pDC = pDC;
        m_pOldBitmap = NULL;
        m_bMemDC = !pDC->IsPrinting();
              
        if (m_bMemDC)    // Create a Memory DC
        {
            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        // Make a copy of the relevent parts of the current DC for printing
        {
            m_bPrinting = pDC->m_bPrinting;
            m_hDC       = pDC->m_hDC;
            m_hAttribDC = pDC->m_hAttribDC;
        }
    }
    
    // Destructor copies the contents of the mem DC to the original DC
    ~CMemDC()
    {
        if (m_bMemDC) 
        {    
            // Copy the offscreen bitmap onto the screen.
            m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
                          this, m_rect.left, m_rect.top, SRCCOPY);

            //Swap back the original bitmap.
            SelectObject(m_pOldBitmap);
        } else {
            // All we need to do is replace the DC with an illegal value,
            // this keeps us from accidently deleting the handles associated with
            // the CDC that was passed to the constructor.
            m_hDC = m_hAttribDC = NULL;
        }
    }

    // Allow usage as a pointer
    CMemDC* operator->() {return this;}
        
    // Allow usage as a pointer
    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 // !defined(AFX_BTNST_H__54BEB054_145A_4DCD_B52A_1E2B86BC03B3__INCLUDED_)

⌨️ 快捷键说明

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