#include #include "windows.h" #include "DualPtrList.h" #ifndef DECLARE_USER_MESSAGE #define DECLARE_USER_MESSAGE(name) \ const UINT name = ::RegisterWindowMessage(name##_MSG); #endif #define WMU_HITCAPBUTTON_MSG _T("WMU_HITCAPBUTTON--{46CB2AA1-EB38-48ab-A4EC-D7C1D5D15648}") #if !defined(AFX_CAPTIONBUTTON_H__8579D0A0_FD12_4476_8235_526DCF123FD9__INCLUDED_) #define AFX_CAPTIONBUTTON_H__8579D0A0_FD12_4476_8235_526DCF123FD9__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 //#define WMU_HITCAPBUTTON WM_APP + 15 extern const UINT WMU_HITCAPBUTTON; class CCapToolTip:public CToolTipCtrl { public: BOOL AddToolTip( UINT nID, LPRECT lpRect, LPCTSTR lpszText ); }; class CCapBtnWnd; class CCaptionButton :public CWnd { public: CCapBtnWnd *m_pParent; CString m_sTip; CRect m_rc; // caption/button rectangle UINT m_idBmpUp; // bitmap ID UINT m_idBmpDown; // bitmap ID UINT m_uiBtnCount; // No. of buttons BOOL m_bCheckBtn; // check button TRUE/FALSE BOOL m_bBtnChecked; // button is checked TRUE/FALSE BOOL m_bHighLight; // mouse hovers over a button TRUE/FALSE BOOL m_bEnable; // button is enabled TRUE/FALSE COLORADJUSTMENT *m_CAdj; // structure to adjust the color of the bitmap TRACKMOUSEEVENT m_TME; public: CCaptionButton(const TCHAR*sTip,UINT ID_Bmp_up, UINT ID_Bmp_down, BOOL bCheckBtn/*= FALSE*/); virtual ~CCaptionButton(); void SetChecked(bool bCheck){m_bBtnChecked=bCheck;}//ok UINT GetIndex()const{return m_uiBtnCount;} void SetIndex(UINT i){m_uiBtnCount=i;}//ok void SetParent(CCapBtnWnd*pParent); BOOL EnableButton(BOOL bEnable); HWND GetHWnd()const; void CalcCapRect(); BOOL PaintBmpCheckBtn(); BOOL ButtonHitTest( CPoint point, BOOL bHover = FALSE); }; class CCapBtnWnd { protected: HWND m_hWndCap; // Handle of the window that receives the button WNDPROC m_pWndProcOld; BOOL m_bActive; // state of the window/dialogue DualPtrList m_lstBtn; public: CCapToolTip m_ctrlTip; public: CCapBtnWnd(); virtual ~CCapBtnWnd(); HWND GetHWnd()const{return m_hWndCap;}//ok void Hook(HWND hWnd); void AddCapBtn(CCaptionButton*pBtn); bool IsHooked()const{return m_pWndProcOld!=NULL;}//ok void UnHook(); BOOL IsWindowActive(BOOL &bActive); LRESULT HookProc(UINT message, WPARAM wParam, LPARAM lParam); }; inline void CCaptionButton::SetParent(CCapBtnWnd*pParent){m_pParent=pParent;}//ok inline HWND CCaptionButton::GetHWnd()const{return m_pParent->GetHWnd();}//ok #endif // !defined(AFX_CAPTIONBUTTON_H__8579D0A0_FD12_4476_8235_526DCF123FD9__INCLUDED_)