editinfodlg.h

来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C头文件 代码 · 共 83 行

H
83
字号
#if !defined(AFX_EDITINFODLG_H__E137C797_6FFE_4D5E_9EB0_0471A29B80F2__INCLUDED_)
#define AFX_EDITINFODLG_H__E137C797_6FFE_4D5E_9EB0_0471A29B80F2__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CEditInfoDlg dialog
#include "Afxtempl.h"

class CItemInfo//一项信息
{
public:
	enum STATE  {STATE_NORMAL , STATE_DISABLE , STATE_HIDE } ;//编辑框状态类型
	CItemInfo(CString strName,CString strDefaultValue,STATE state = STATE_NORMAL)
	{
		i_strName = strName ;
		i_strValue = strDefaultValue ;
		i_state = state ;
	};
	CItemInfo(){} ;
	CItemInfo& operator=(const CItemInfo& other)
	{
		i_strName	= other.i_strName ;
		i_strValue	= other.i_strValue ;
		//i_wndStatic ,iWndEdit不需要赋值,也不能赋值
		i_state		= other.i_state ;
		return *this ;
	};
	CString i_strName ;//项名
	CString i_strValue ;//项值
	CStatic	i_wndStatic;//静态文本框
	CEdit   i_wndEdit ;//编辑框
	STATE	i_state ;//状态
};

class CEditInfoDlg : public CDialog
{
public:
	void SetItemsState(CItemInfo::STATE state);//设置所有项的状态
	void SetAItemState(CString strName,CItemInfo::STATE state) ;//设置一项的状态
	int GetShowItemCount();//得到可视项的个数
	bool AddAItem(CString strName,CString strValue);//增加一项
	CEditInfoDlg(CWnd* pParent = NULL);   // standard constructor
	~CEditInfoDlg();
	CString		i_strTitle ;//对话框标题
	//{{AFX_DATA(CEditInfoDlg)
	enum { IDD = IDD_EDIT_INFO };
	// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA
	//{{AFX_VIRTUAL(CEditInfoDlg)
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL
	
	// Implementation
protected:
	CArray<CItemInfo,CItemInfo&>		m_Items ;//项数组
	int		m_iStaticWidth ;  //静态文本框的宽度
	int		m_iEditWidth ;    //编辑框宽度
	int		m_iHeight ;		  //静态文本框和编辑框高度	
	int		m_iRowSpacing ;   //行距
	int		m_iColSpacing ;   //列距
	
	bool CreateControl() ;    //建立控件(静态文本框、编辑框)
	// Generated message map functions
	//{{AFX_MSG(CEditInfoDlg)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:
	void MoveDlgAndBtn();
};

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

#endif // !defined(AFX_EDITINFODLG_H__E137C797_6FFE_4D5E_9EB0_0471A29B80F2__INCLUDED_)

⌨️ 快捷键说明

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