📄 timegridctrl.h
字号:
/////////////////////////////////////////////////////////////////////////////
// GridCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _GRIDCTRL_H_
#define _GRIDCTRL_H_
#include "GridCell.h"
#define GRIDCTRL_CLASSNAME _T("MFCTimeGridCtrl")
///////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////
class CTimeGridCtrl;
//void AFXAPI DDX_GridControl(CDataExchange* pDX, int nIDC, CTimeGridCtrl& rControl);
/////////////////////////////////////////////////////////////////////////////
// CTimeGridCtrl window
/////////////////////////////////////////////////////////////////////////////
class CTimeGridCtrl : public CWnd
{
// Construction
public:
CTimeGridCtrl();
DECLARE_DYNCREATE(CTimeGridCtrl)
// Operations
public:
BOOL m_bCreated;
BOOL Create(const RECT& rect, CWnd* parent, UINT nID,
DWORD dwStyle = WS_CHILD | WS_TABSTOP | WS_VISIBLE);
void CreateTooltips();
BOOL DeleteAllItems();
BOOL SubclassWindow(HWND hWnd);
BOOL SetCols();
BOOL GetCellRect(int nRow, int nCol, LPRECT pRect) const;
void RedrawCell(int nRow, int nCol);
int GetCellStates(int nRow, int nCol);
void SetValidCell(int nRow,int nCol);
void SetNoValid();
BOOL GetValidCell(int nRow,int nCol);
void SetSelectCell(int nRow,int nCol,int nSelect);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTimeGridCtrl)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
public:
CGridCell* GetCell(int nRow, int nCol) const;
BOOL SetCell(int nRow, int nCol, CGridCell* pCell);
// Implementation
public:
virtual ~CTimeGridCtrl();
protected:
BOOL RegisterWindowClass();
CGridCell* GetCellFromPt(CPoint point,int &nRow,int &nCol);
// Overrrides
protected:
// Drawing
virtual void OnDraw(CDC* pDC);
BOOL DrawHourLabel(CDC* pDC, int nRow, CRect rect);
BOOL DrawMinuateLabel(CDC* pDC,int nCol, CRect rect);
void DrawCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk=FALSE);
virtual CGridCell* CreateCell(int nRow, int nCol);
// Attributes
public:
CView* m_pParentWnd;
int m_nRows,m_nFixedRows,m_nCols,m_nFixedCols,
m_nDefCellWidth, m_nDefCellHeight,m_nFixedCellWidth,m_nFixedColHeight;
CPoint m_nLastPoint;
CToolTipCtrl* m_pToolTip;
CRect m_rectSearch;
protected:
// General attributes
// Cell size details
// Fonts and images
CTypedPtrArray<CObArray, GRID_ROW*> m_RowData;
// Printing information
protected:
// Generated message map functions
//{{AFX_MSG(CTimeGridCtrl)
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMH, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
};
inline CGridCell* CTimeGridCtrl::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 CTimeGridCtrl::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;
}
/////////////////////////////////////////////////////////////////////////////
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -