formlistctrl.h

来自「基于WINDOWS mobile 的用于创建一个窗体和自定义试图的工程」· C头文件 代码 · 共 154 行

H
154
字号
#if !defined(AFX_FORMLISTCTRL_H__43F667A9_E157_45A4_B271_872448A4245A__INCLUDED_)
#define AFX_FORMLISTCTRL_H__43F667A9_E157_45A4_B271_872448A4245A__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// FormListCtrl.h : header file
//


#include "BaseListCtrl.h"
#include "FormItem.h"


class CFormItemString;
class CFormItemDateTime;
class CFormItemGroup;
class CFormItemCheck;


#define WM_ADJUSTSIP	(WM_USER + 0x500)
#define WM_SELECT_NEXT	(WM_USER + 0x501)
#define WM_SELECT_PREV	(WM_USER + 0x502)
#define WM_CLOSE_EDITOR	(WM_USER + 0x503)


//---------------------------------------------------------------------------
//
//	CFormListCtrl window
//
//---------------------------------------------------------------------------


class CFormListCtrl : public CBaseListCtrl
{
// Construction
public:
	CFormListCtrl();

// Attributes
public:

// Operations
public:

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CFormListCtrl)
	public:
	virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
	protected:
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CFormListCtrl();

	void AddItem(CFormItem *pItem, int iItem = -1) 
	{
		ASSERT(pItem); 
		pItem->InsertOn(this, iItem);
	}

	BOOL RemoveItem(CFormItem *pItem);

	int FindFormItem(CFormItem* pItem);

	void	SetRowHeight(int nHeight);
	int		HitTestEx(CPoint &point, int *pSubItem);

	//
	// Accessors
	//
	BOOL	GetSubItemRect	(int iItem, int iSubItem, RECT &rc);
	CFont*	GetContentFont	()	{ return &m_fontBig;		}
	CFont*	GetBoldFont		()	{ return &m_fontBold;	}
	CFont*	GetUnderlineFont()	{ return &m_fontUnder;	}
	int		GetEditIndex	()	{ return m_iEdit;		}
	int		GetSelectedIndex()	{ return m_iSelected;	}
	CPoint	GetClickPoint	()	{ return m_ptClick;		}

	void	SetEditIndex	(int iEdit)	{ m_iEdit = iEdit; }

	/// Validates the form's data.
	BOOL ValidateData();

	void EnableEdit(bool bEditable = true) { m_bEditable = bEditable; }

	virtual void ItemUpdated(CFormItem* pItem, DWORD dwData);
	virtual void ItemOptions(CFormItem* pItem);

	//
	// Initialization
	//
	virtual BOOL Initialize();

protected:
	CImageList		m_imglHeight;		//!< Used only for row heights.
	CFont			m_fontBig,			//!< Big font used for content.
					m_fontUnder,		//!< Underlined font
					m_fontBold;			//!< Bold font used for headings.
	int				m_iEdit,			//!< Item being edited (-1 if none).
					m_iSelected;		//!< Selected item (-1 if none).
	bool			m_bEditable,		//!< False for read-only
					m_bResizing;		//!< Columns are being resized by the user
	CPoint			m_ptClick;			//!< Point of click selection.
	CFormItemGroup*	m_pGroup;			//!< Current group

	// Generated message map functions
	//{{AFX_MSG(CFormListCtrl)
	afx_msg void OnCustomDraw	(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnGetDispInfo	(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDestroy		();
	afx_msg void OnVScroll		(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnSize			(UINT nType, int cx, int cy);
	//}}AFX_MSG

	void	ResizeDataColumn();
	void	MoveDivider		(int dx);
	void	SelectItem		(int iItem, BOOL bSelect);
	bool	CloseEditor		();


	void DrawDivider(int x);
	void LineVert(HDC hDC, int x, int y0, int y1)
	{
		POINT	line[2] = {{x, y0}, {x, y1}};

		DRA::Polyline(hDC, line, 2, DRA::PS_DOWNRIGHT);
	}

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void	OnLButtonDown	(UINT nFlags, CPoint point);
	afx_msg void	OnLButtonUp		(UINT nFlags, CPoint point);
	afx_msg void	OnMouseMove		(UINT nFlags, CPoint point);
	afx_msg LRESULT OnAdjustSip		(WPARAM, LPARAM);
	afx_msg LRESULT OnSelectNext	(WPARAM, LPARAM);
	afx_msg LRESULT OnSelectPrev	(WPARAM, LPARAM);
	afx_msg LRESULT OnCloseEditor	(WPARAM, LPARAM);
	afx_msg void	OnKeyDown		(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
};


//---------------------------------------------------------------------------


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FORMLISTCTRL_H__43F667A9_E157_45A4_B271_872448A4245A__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?