📄 afxext.h
字号:
// standard control bar things
int CommandToIndex(UINT nIDFind) const;
UINT GetItemID(int nIndex) const;
virtual void GetItemRect(int nIndex, LPRECT lpRect) const;
UINT GetButtonStyle(int nIndex) const;
void SetButtonStyle(int nIndex, UINT nStyle);
// for changing button info
void GetButtonInfo(int nIndex, UINT& nID, UINT& nStyle, int& iImage) const;
void SetButtonInfo(int nIndex, UINT nID, UINT nStyle, int iImage);
BOOL SetButtonText(int nIndex, LPCTSTR lpszText);
CString GetButtonText(int nIndex) const;
void GetButtonText(int nIndex, CString& rString) const;
// for direct access to the underlying common control
CToolBarCtrl& GetToolBarCtrl() const;
// Implementation
public:
virtual ~CToolBar();
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
void SetOwner(CWnd* pOwnerWnd);
BOOL AddReplaceBitmap(HBITMAP hbmImageWell);
virtual void OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle);
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
HRSRC m_hRsrcImageWell; // handle to loaded resource for image well
HINSTANCE m_hInstImageWell; // instance handle to load image well from
HBITMAP m_hbmImageWell; // contains color mapped button images
BOOL m_bDelayedButtonLayout; // used to manage when button layout should be done
CSize m_sizeImage; // current image size
CSize m_sizeButton; // current button size
CMapStringToPtr* m_pStringMap; // used as CMapStringToUInt
// implementation helpers
void _GetButton(int nIndex, TBBUTTON* pButton) const;
void _SetButton(int nIndex, TBBUTTON* pButton);
CSize CalcLayout(DWORD nMode, int nLength = -1);
CSize CalcSize(TBBUTTON* pData, int nCount);
int WrapToolBar(TBBUTTON* pData, int nCount, int nWidth);
void SizeToolBar(TBBUTTON* pData, int nCount, int nLength, BOOL bVert = FALSE);
void Layout(); // called for for delayed button layout
//{{AFX_MSG(CToolBar)
afx_msg UINT OnNcHitTest(CPoint);
afx_msg void OnNcPaint();
afx_msg void OnPaint();
afx_msg void OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*);
afx_msg void OnWindowPosChanging(LPWINDOWPOS);
afx_msg void OnSysColorChange();
afx_msg LRESULT OnSetButtonSize(WPARAM, LPARAM);
afx_msg LRESULT OnSetBitmapSize(WPARAM, LPARAM);
afx_msg LRESULT OnPreserveZeroBorderHelper(WPARAM, LPARAM);
afx_msg BOOL OnNcCreate(LPCREATESTRUCT);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
LRESULT OnSetSizeHelper(CSize& size, LPARAM lParam);
};
// Styles for toolbar buttons
#define TBBS_BUTTON MAKELONG(TBSTYLE_BUTTON, 0) // this entry is button
#define TBBS_SEPARATOR MAKELONG(TBSTYLE_SEP, 0) // this entry is a separator
#define TBBS_CHECKBOX MAKELONG(TBSTYLE_CHECK, 0) // this is an auto check button
#define TBBS_GROUP MAKELONG(TBSTYLE_GROUP, 0) // marks the start of a group
#define TBBS_CHECKGROUP (TBBS_GROUP|TBBS_CHECKBOX) // normal use of TBBS_GROUP
#define TBBS_DROPDOWN MAKELONG(TBSTYLE_DROPDOWN, 0) // drop down style
#define TBBS_AUTOSIZE MAKELONG(TBSTYLE_AUTOSIZE, 0) // autocalc button width
#define TBBS_NOPREFIX MAKELONG(TBSTYLE_NOPREFIX, 0) // no accel prefix for this button
// styles for display states
#define TBBS_CHECKED MAKELONG(0, TBSTATE_CHECKED) // button is checked/down
#define TBBS_PRESSED MAKELONG(0, TBSTATE_PRESSED) // button is being depressed
#define TBBS_DISABLED MAKELONG(0, TBSTATE_ENABLED) // button is disabled
#define TBBS_INDETERMINATE MAKELONG(0, TBSTATE_INDETERMINATE) // third state
#define TBBS_HIDDEN MAKELONG(0, TBSTATE_HIDDEN) // button is hidden
#define TBBS_WRAPPED MAKELONG(0, TBSTATE_WRAP) // button is wrapped at this point
#define TBBS_ELLIPSES MAKELONG(0, TBSTATE_ELIPSES)
#define TBBS_MARKED MAKELONG(0, TBSTATE_MARKED)
////////////////////////////////////////////
// CDialogBar control
// This is a control bar built from a dialog template. It is a modeless
// dialog that delegates all control notifications to the parent window
// of the control bar [the grandparent of the control]
class CDialogBar : public CControlBar
{
DECLARE_DYNAMIC(CDialogBar)
// Construction
public:
CDialogBar();
BOOL Create(CWnd* pParentWnd, LPCTSTR lpszTemplateName,
UINT nStyle, UINT nID);
BOOL Create(CWnd* pParentWnd, UINT nIDTemplate,
UINT nStyle, UINT nID);
// Implementation
public:
virtual ~CDialogBar();
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
CSize m_sizeDefault;
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
protected:
#ifndef _AFX_NO_OCC_SUPPORT
// data and functions necessary for OLE control containment
_AFX_OCC_DIALOG_INFO* m_pOccDialogInfo;
LPCTSTR m_lpszTemplateName;
virtual BOOL SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo);
//{{AFX_MSG(CDialogBar)
DECLARE_MESSAGE_MAP()
//}}AFX_MSG
afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM);
#endif
};
////////////////////////////////////////////
// CReBar control
class CReBarCtrl;
class CReBar : public CControlBar
{
DECLARE_DYNAMIC(CReBar)
// Construction
public:
CReBar();
BOOL Create(CWnd* pParentWnd, DWORD dwCtrlStyle = RBS_BANDBORDERS,
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP,
UINT nID = AFX_IDW_REBAR);
// Attributes
public:
// for direct access to the underlying common control
CReBarCtrl& GetReBarCtrl() const;
// Operations
public:
BOOL AddBar(CWnd* pBar, LPCTSTR pszText = NULL, CBitmap* pbmp = NULL,
DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP);
BOOL AddBar(CWnd* pBar, COLORREF clrFore, COLORREF clrBack,
LPCTSTR pszText = NULL, DWORD dwStyle = RBBS_GRIPPERALWAYS);
// Implementation
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
#ifdef _DEBUG
void EnableDocking(DWORD dwDockStyle);
#endif
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
BOOL _AddBar(CWnd* pBar, REBARBANDINFO* pRBBI);
//{{AFX_MSG(CReBar)
afx_msg BOOL OnNcCreate(LPCREATESTRUCT);
afx_msg void OnPaint();
afx_msg void OnHeightChange(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnNcPaint();
afx_msg void OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg LRESULT OnShowBand(WPARAM wParam, LPARAM lParam);
afx_msg void OnRecalcParent();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// Splitter Window
#define SPLS_DYNAMIC_SPLIT 0x0001
#define SPLS_INVERT_TRACKER 0x0002 // obsolete (now ignored)
class CSplitterWnd : public CWnd
{
DECLARE_DYNAMIC(CSplitterWnd)
// Construction
public:
CSplitterWnd();
// Create a single view type splitter with multiple splits
BOOL Create(CWnd* pParentWnd,
int nMaxRows, int nMaxCols, SIZE sizeMin,
CCreateContext* pContext,
DWORD dwStyle = WS_CHILD | WS_VISIBLE |
WS_HSCROLL | WS_VSCROLL | SPLS_DYNAMIC_SPLIT,
UINT nID = AFX_IDW_PANE_FIRST);
// Create a multiple view type splitter with static layout
BOOL CreateStatic(CWnd* pParentWnd,
int nRows, int nCols,
DWORD dwStyle = WS_CHILD | WS_VISIBLE,
UINT nID = AFX_IDW_PANE_FIRST);
virtual BOOL CreateView(int row, int col, CRuntimeClass* pViewClass,
SIZE sizeInit, CCreateContext* pContext);
// Attributes
public:
int GetRowCount() const;
int GetColumnCount() const;
// information about a specific row or column
void GetRowInfo(int row, int& cyCur, int& cyMin) const;
void SetRowInfo(int row, int cyIdeal, int cyMin);
void GetColumnInfo(int col, int& cxCur, int& cxMin) const;
void SetColumnInfo(int col, int cxIdeal, int cxMin);
// for setting and getting shared scroll bar style
DWORD GetScrollStyle() const;
void SetScrollStyle(DWORD dwStyle);
// views inside the splitter
CWnd* GetPane(int row, int col) const;
BOOL IsChildPane(CWnd* pWnd, int* pRow, int* pCol);
BOOL IsChildPane(CWnd* pWnd, int& row, int& col); // obsolete
int IdFromRowCol(int row, int col) const;
BOOL IsTracking(); // TRUE during split operation
// Operations
public:
virtual void RecalcLayout(); // call after changing sizes
// Overridables
protected:
// to customize the drawing
enum ESplitType { splitBox, splitBar, splitIntersection, splitBorder };
virtual void OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rect);
virtual void OnInvertTracker(const CRect& rect);
public:
// for customizing scrollbar regions
virtual BOOL CreateScrollBarCtrl(DWORD dwStyle, UINT nID);
// for customizing DYNAMIC_SPLIT behavior
virtual void DeleteView(int row, int col);
virtual BOOL SplitRow(int cyBefore);
virtual BOOL SplitColumn(int cxBefore);
virtual void DeleteRow(int rowDelete);
virtual void DeleteColumn(int colDelete);
// determining active pane from focus or active view in frame
virtual CWnd* GetActivePane(int* pRow = NULL, int* pCol = NULL);
virtual void SetActivePane(int row, int col, CWnd* pWnd = NULL);
protected:
CWnd* GetActivePane(int& row, int& col); // obsolete
public:
// high level command operations - called by default view implementation
virtual BOOL CanActivateNext(BOOL bPrev = FALSE);
virtual void ActivateNext(BOOL bPrev = FALSE);
virtual BOOL DoKeyboardSplit();
// synchronized scrolling
virtual BOOL DoScroll(CView* pViewFrom, UINT nScrollCode,
BOOL bDoScroll = TRUE);
virtual BOOL DoScrollBy(CView* pViewFrom, CSize sizeScroll,
BOOL bDoScroll = TRUE);
// Implementation
public:
virtual ~CSplitterWnd();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// implementation structure
struct CRowColInfo
{
int nMinSize; // below that try not to show
int nIdealSize; // user set size
// variable depending on the available size layout
int nCurSize; // 0 => invisible, -1 => nonexistant
};
protected:
// customizable implementation attributes (set by constructor or Create)
CRuntimeClass* m_pDynamicViewClass;
int m_nMaxRows, m_nMaxCols;
// implementation attributes which control layout of the splitter
int m_cxSplitter, m_cySplitter; // size of splitter bar
int m_cxBorderShare, m_cyBorderShare; // space on either side of splitter
int m_cxSplitterGap, m_cySplitterGap; // amount of space between panes
int m_cxBorder, m_cyBorder; // borders in client area
// current state information
int m_nRows, m_nCols;
BOOL m_bHasHScroll, m_bHasVScroll;
CRowColInfo* m_pColInfo;
CRowColInfo* m_pRowInfo;
// Tracking info - only valid when 'm_bTracking' is set
BOOL m_bTracking, m_bTracking2;
CPoint m_ptTrackOffset;
CRect m_rectLimit;
CRect m_rectTracker, m_rectTracker2;
int m_htTrack;
// implementation routines
BOOL CreateCommon(CWnd* pParentWnd, SIZE sizeMin, DWORD dwStyle, UINT nID);
virtual int HitTest(CPoint pt) const;
virtual void GetInsideRect(CRect& rect) const;
virtual void GetHitRect(int ht, CRect& rect);
virtual void TrackRowSize(int y, int row);
virtual void TrackColumnSize(int x, int col);
virtual void DrawAllSplitBars(CDC* pDC, int cxInside, int cyInside);
virtual void SetSplitCursor(int ht);
CWnd* GetSizingParent();
// starting and stopping tracking
virtual void StartTracking(int ht);
virtual void StopTracking(BOOL bAccept);
// special command routing to frame
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
//{{AFX_MSG(CSplitterWnd)
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnMouseMove(UINT nFlags, CPoint pt);
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint pt);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint pt);
afx_msg void OnLButtonUp(UINT nFlags, CPoint pt);
afx_msg void OnCancelMode();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpcs);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnDisplayChange();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CFormView - generic view constructed from a dialog template
class CFormView : public CScrollView
{
DECLARE_DYNAMIC(CFormView)
// Construction
protected: // must derive your own class
CFormView(LPCTSTR lpszTemplateName);
CFormView(UINT nIDTemplate);
// Implementation
public:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -