📄 gridctrl.h
字号:
void ExpandToFit();
// SetRedraw stops/starts redraws on things like changing the # rows/columns
// and autosizing, but not for user-intervention such as resizes
void SetRedraw(BOOL bAllowDraw, BOOL bResetScrollBars = FALSE);
BOOL RedrawCell(int nRow, int nCol, CDC* pDC = NULL);
BOOL RedrawCell(const CCellID& cell, CDC* pDC = NULL);
BOOL RedrawRow(int row);
BOOL RedrawColumn(int col);
void Print();
CCellRange GetCellRange();
CCellRange GetSelectedCellRange();
void SetSelectedRange(const CCellRange& Range, BOOL bForceRepaint = FALSE);
void SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMaxCol,
BOOL bForceRepaint = FALSE);
BOOL IsValid(int nRow, int nCol);
BOOL IsValid(const CCellID& cell);
BOOL IsValid(const CCellRange& range);
// Clipboard and cut n' paste operations
virtual void CutSelectedText();
virtual COleDataSource* CopyTextFromGrid();
virtual BOOL PasteTextToGrid(CCellID cell, COleDataObject* pDataObject);
void OnBeginDrag();
DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
void OnDragLeave();
BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
virtual void OnEditCut();
virtual void OnEditCopy();
virtual void OnEditPaste();
CCellID GetNextItem(CCellID& cell, int nFlags) const;
BOOL SortTextItems(int nCol, BOOL bAscending);
BOOL SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data = 0);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGridCtrl)
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
public:
virtual void OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo);
virtual void OnPrint(CDC *pDC, CPrintInfo *pInfo);
virtual void OnEndPrinting(CDC *pDC, CPrintInfo *pInfo);
// Implementation
public:
virtual ~CGridCtrl();
protected:
BOOL RegisterWindowClass();
BOOL IsCellVisible(int nRow, int nCol);
BOOL IsCellVisible(CCellID cell);
BOOL InvalidateCellRect(const CCellID& cell);
BOOL InvalidateCellRect(const CCellRange& cellRange);
void EraseBkgnd(CDC* pDC);
CSize GetTextExtent(LPCTSTR str);
BOOL GetCellRangeRect(const CCellRange& cellRange, LPRECT lpRect);
CGridCell* GetCell(int nRow, int nCol) const;
BOOL SetCell(int nRow, int nCol, CGridCell* pCell);
int SetMouseMode(int nMode) { int nOldMode = m_MouseMode; m_MouseMode = nMode; return nOldMode; }
int GetMouseMode() { return m_MouseMode; }
CCellID GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck = TRUE);
CCellID GetTopleftNonFixedCell();
CCellRange GetUnobstructedNonFixedCellRange();
CCellRange GetVisibleNonFixedCellRange(LPRECT pRect = NULL);
CCellID SetFocusCell(CCellID cell);
CCellID SetFocusCell(int nRow, int nCol);
void ResetSelectedRange();
void ResetScrollBars();
int GetGridScrollPos(int nBar);
BOOL SetGridScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE);
BOOL SortTextItems(int nCol, BOOL bAscending, int low, int high);
BOOL SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data,
int low, int high);
// Overrrides
protected:
// Printing
virtual void PrintColumnHeadings(CDC *pDC, CPrintInfo *pInfo);
virtual void PrintHeader(CDC *pDC, CPrintInfo *pInfo);
virtual void PrintFooter(CDC *pDC, CPrintInfo *pInfo);
// Drag n' drop
virtual CImageList* CreateDragImage(CPoint *pHotSpot); // no longer necessary
// Mouse Clicks
virtual void OnFixedColumnClick(CCellID& cell);
virtual void OnFixedRowClick(CCellID& cell);
// Editing
virtual CSize GetCellExtent(int nRow, int nCol, CDC* pDC);
virtual void OnEndEditCell(int nRow, int nCol, CString str);
virtual void OnEditCell(int nRow, int nCol, UINT nChar);
// Drawing
virtual void OnDraw(CDC& origDC);
virtual BOOL DrawFixedCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk=FALSE);
virtual BOOL DrawCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk=FALSE);
// Fill List Content
virtual void FillListItems(int nCol, LPARAM cltList);
// Cleanup
virtual void EmptyCell(CGridCell* pCell, int nRow, int nCol);
// Attributes
protected:
// General attributes
COLORREF m_crTextColour, m_crTextBkColour, m_crBkColour, // Grid colours
m_crFixedTextColour, m_crFixedBkColour;
COLORREF m_crWindowText, m_crWindowColour, m_cr3DFace, // System colours
m_crShadow;
int m_nGridLines;
BOOL m_bEditable;
BOOL m_bModified;
BOOL m_bAllowDragAndDrop;
BOOL m_bListMode;
BOOL m_bAllowDraw;
BOOL m_bEnableSelection;
BOOL m_bSortOnClick;
// Cell size details
int m_nRows, m_nFixedRows, m_nCols, m_nFixedCols;
CUIntArray m_arRowHeights, m_arColWidths, m_arColType;
int m_nMargin;
int m_nDefCellWidth, m_nDefCellHeight;
int m_nVScrollMax, m_nHScrollMax;
// Fonts and images
CFont m_Font, m_PrinterFont;
CImageList* m_pImageList;
// Cell data
CTypedPtrArray<CObArray, GRID_ROW*> m_RowData;
// Mouse operations such as cell selection
int m_MouseMode;
CPoint m_LeftClickDownPoint, m_LastMousePoint;
CCellID m_LeftClickDownCell, m_SelectionStartCell;
CCellID m_idCurrentCell;
int m_nTimerID;
int m_nTimerInterval;
BOOL m_bAllowRowResize, m_bAllowColumnResize;
int m_nRowsPerWheelNotch;
CMap<DWORD,DWORD, CCellID, CCellID&> m_SelectedCellMap, m_PrevSelectedCellMap;
// Drag and drop
CImageList* m_pDragImage;
CWnd* m_pDropWnd;
CCellID m_LastDragOverCell;
CGridDropTarget m_DropTarget;
// Printing information
CSize m_CharSize;
int m_nPageHeight;
CSize m_LogicalPageSize, // Page size in gridctrl units.
m_PaperSize; // Page size in device units.
// sorting
int m_bAscending;
int m_SortColumn;
protected:
void SelectAllCells();
void SelectColumns(CCellID currentCell);
void SelectRows(CCellID currentCell);
void SelectCells(CCellID currentCell);
void OnSelecting(const CCellID& currentCell);
// Generated message map functions
//{{AFX_MSG(CGridCtrl)
afx_msg void OnPaint();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnCaptureChanged(CWnd *pWnd);
afx_msg UINT OnGetDlgCode();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
afx_msg void OnSysColorChange();
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
//}}AFX_MSG
afx_msg LRESULT OnSetFont(WPARAM hFont, LPARAM lParam);
afx_msg LRESULT OnGetFont(WPARAM hFont, LPARAM lParam);
afx_msg LRESULT OnFillList(WPARAM nColumn, LPARAM pListBox);
afx_msg BOOL OnEndInPlaceEdit(NMHDR* pNMHDR, LRESULT* pResult);
DECLARE_MESSAGE_MAP()
enum eMouseModes { MOUSE_NOTHING, MOUSE_SELECT_ALL, MOUSE_SELECT_COL, MOUSE_SELECT_ROW,
MOUSE_SELECT_CELLS, MOUSE_SCROLLING_CELLS,
MOUSE_OVER_ROW_DIVIDE, MOUSE_SIZING_ROW,
MOUSE_OVER_COL_DIVIDE, MOUSE_SIZING_COL,
MOUSE_PREPARE_EDIT, MOUSE_PREPARE_DRAG, MOUSE_DRAGGING};
};
inline CGridCell* CGridCtrl::GetCell(int nRow, int nCol) const
{
if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols) return NULL;
GRID_ROW* pRow = m_RowData[nRow];
if (!pRow) return NULL;
return pRow->GetAt(nCol);
}
inline BOOL CGridCtrl::SetCell(int nRow, int nCol, CGridCell* pCell)
{
if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols) return FALSE;
GRID_ROW* pRow = m_RowData[nRow];
if (!pRow) return FALSE;
pRow->SetAt(nCol, pCell);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GRIDCTRL_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -