#pragma once #include "TWFlag.h" #include "DualPtrList.h" /////////////////////////////////////////////////////////////////////////////////// #define WG_MES_GETSTATUS WM_USER+1 #define WG_MES_SETSTATUS WM_USER+2 #define WG_MES_CHILDSIZE WM_USER+3 #define WG_BUTTON_OFFSET 4 #define WG_MIN_SPACE 3 #define WG_GROUP_DIALGOG_YSPACE 8 #define WG_GROUP_DIALGOG_XSPACE 12 #define WG_ST_HORZ 0x00001//水平打开 #define WG_ST_NOAUTOFOLD 0x00002//尽量不自动折叠 #define WG_ST_ICONBUTTON 0x00004//图标button ///////////////////////////////////////////////////////////////////////// inline bool operator> (CRect,CRect){return false;} inline bool operator< (CRect,CRect){return false;} class WGroupCtrls; //可折叠组合框 class WGroupCtrl : public CStatic,public TWFlag { DECLARE_DYNAMIC(WGroupCtrl) protected: int m_nExtent;//展开大小 BOOL m_bOverControl;//焦点在本窗口 BOOL m_bOpen; DualPtrList m_lstWinHandle;//组内窗口 DualPtrList m_lstWinRect;//组内窗口的相对坐标 WGroupCtrls *m_pGroup; CToolTipCtrl m_ctrlToolTip; CString m_sTipFold,m_sTipUnfold; public: WGroupCtrl(int flag=0); virtual ~WGroupCtrl(); int GetUnfoldExtent(){return m_nExtent;}//ok void SetUnfoldExtent(int size){m_nExtent=size;}//ok CRect GetButtonRect(); void Refresh(); BOOL IsOpened()const{return m_bOpen;}//ok BOOL IsVert()const{return IsNot(WG_ST_HORZ);}//ok WGroupCtrls* GetGroup(){return m_pGroup;}//ok void SetGroup(WGroupCtrls*p){m_pGroup=p;}//ok void SetTip(const TCHAR* sTipFold,const TCHAR* sTipUnfold){m_sTipFold=sTipFold;m_sTipUnfold=sTipUnfold;}//ok void Fold(); void UnFold(); protected: DECLARE_MESSAGE_MAP() LRESULT OnGetStatus(WPARAM, LPARAM); LRESULT OnSetStatus(WPARAM bOpen, LPARAM); afx_msg void OnPaint(); afx_msg LRESULT OnNcHitTest(CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags,CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags,CPoint point); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnCaptureChanged(CWnd* pWnd); protected: virtual void PreSubclassWindow(); virtual BOOL PreTranslateMessage(MSG* pMsg); }; //组合框集合,有联动关系 class WGroupCtrls:public DualPtrList { public: int m_nMaxOpenNum;//最多可以展开组数目,0代表没有限制, int m_nMaxExtent;//最大可以展开的范围,0代表没限制,m_nMaxOpenNum必须为1! public: WGroupCtrls(int num=0):m_nMaxOpenNum(num),m_nMaxExtent(0){}//ok void SetMaxExtent(int size);//设最大可以展开的范围,m_nMaxOpenNum必须为1! void Append(WGroupCtrl*pCtrl);//将WGroupCtrl加入组 void OnBeforeUnfold(WGroupCtrl*pCtrl); }; void DDX_GroupStatus(CDataExchange* pDX, int nIDC, int& value);//组状态(展开、折叠)数据交换