📄 staticsplitterwnd.h
字号:
#ifndef __STATIC_SPLITTER_WND_H__
#define __STATIC_SPLITTER_WND_H__
//静态切分窗口,这个类是从WTL的SplitterWnd里面扒出来的,因为MFC的SplitterWnd实在是
//太太太难用了,而且很难看,看到WTL里面的这个不错,想拿来用,不过如果是MFC程序的话再
//加上WTL的风格有些不协调,就干脆把它的形式改成MFC的风格了,函数看着挺多,不过常用并
//不多,至于注释嘛,我只是在经常用的函数声明上大概写了几句,相知道具体实现,那就去看
//代码吧:)
#define SPLIT_PANE_LEFT 0
#define SPLIT_PANE_RIGHT 1
#define SPLIT_PANE_TOP SPLIT_PANE_LEFT
#define SPLIT_PANE_BOTTOM SPLIT_PANE_RIGHT
#define SPLIT_PANE_NONE -1
/////////////////////////////////////////////////////////////////////////////
// Splitter extended styles
#define SPLIT_PROPORTIONAL 0x00000001
#define SPLIT_NONINTERACTIVE 0x00000002
#define SPLIT_RIGHTALIGNED 0x00000004
#define SPLIT_BOTTOMALIGNED SPLIT_RIGHTALIGNED
/////////////////////////////////////////////////////////////////////////////
// CStaticSplitterWnd window
class CStaticSplitterWnd: public CWnd
{
enum { m_nPanesCount = 2, m_nPropMax = 10000 };
HWND m_hWndPane[m_nPanesCount];
HCURSOR m_hCursor;
CRect m_rcSplitter;
int m_xySplitterPos;
int m_nDefActivePane;
int m_cxySplitBar; // splitter bar width/height
int m_cxyMin; // minimum pane size
int m_cxyBarEdge; // splitter bar edge
BOOL m_bFullDrag;
int m_cxyDragOffset;
int m_nProportionalPos;
BOOL m_bUpdateProportionalPos;
DWORD m_dwExtendedStyle; // splitter specific extended styles
int m_nSinglePane; // single pane mode
BOOL m_bVertical;
protected:
BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo );
BOOL PreCreateWindow( CREATESTRUCT& cs );
// Generated message map functions
protected:
//{{AFX_MSG(CStaticSplitterWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
afx_msg BOOL OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message );
afx_msg void OnMouseMove( UINT nFlags, CPoint point );
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
afx_msg void OnLButtonUp( UINT nFlags, CPoint point );
afx_msg void OnLButtonDblClk( UINT nFlags, CPoint point );
afx_msg void OnSetFocus( CWnd* pOldWnd );
afx_msg int OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message );
afx_msg LRESULT OnDisplayChange(WPARAM, LPARAM);
afx_msg void OnSize(UINT nType, int cx, int cy );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
protected:
//Overridables
virtual void DrawSplitter(CDC* pDC);
virtual void DrawSplitterBar(CDC* pDC);
virtual void DrawSplitterPane(CDC* pDC, int nPane);
virtual BOOL Create(CWnd* pParent, BOOL bVertical = TRUE, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST);
//常用的几个成员函数
public:
CStaticSplitterWnd();
virtual ~CStaticSplitterWnd();
BOOL CreateVertical(CWnd *pParent, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST);
BOOL CreateHorizonal(CWnd *pParent, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST);
BOOL SetSplitterPos(int xyPos = -1, BOOL bUpdate = TRUE);
int GetSplitterPos() const;
//可以设置成只有一个窗口的模式,也就是隐藏分裂窗口的另外一部分
BOOL SetSinglePaneMode(int nPane = SPLIT_PANE_NONE);
int GetSinglePaneMode() const;
DWORD GetSplitterExtendedStyle() const;
DWORD SetSplitterExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0);
void SetSplitterPanes(CWnd* pWndLeftTop, CWnd* pWndRightBottom, BOOL bUpdate = TRUE);
BOOL SetSplitterPane(int nPane, CWnd* pWnd, BOOL bUpdate = TRUE);
HWND GetSplitterPane(int nPane) const;
BOOL SetActivePane(int nPane);
int GetActivePane() const;
BOOL ActivateNextPane(BOOL bNext = TRUE);
BOOL SetDefaultActivePane(int nPane);
BOOL SetDefaultActivePane(CWnd* pWnd);
int GetDefaultActivePane() const;
void UpdateSplitterLayout();
//下面是一些不常用的函数,大家有兴趣可以看看
public:
void SetSplitterRect(LPRECT lpRect = NULL, BOOL bUpdate = TRUE);;
void GetSplitterRect(LPRECT lpRect) const;
BOOL GetSplitterBarRect(LPRECT lpRect) const;
BOOL GetSplitterPaneRect(int nPane, LPRECT lpRect) const;
void DrawGhostBar();
void GetSystemSettings(BOOL bUpdate);
void StoreProportionalPos();
void UpdateProportionalPos();
void StoreRightAlignPos();
void UpdateRightAlignPos();
BOOL IsOverSplitterRect(int x, int y) const;
BOOL IsOverSplitterBar(int x, int y) const;
BOOL IsProportional() const;
BOOL IsInteractive() const;
BOOL IsRightAligned() const;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -