MFC 编辑框动态创建与多行信息显示

typedef struct _StateInfo
{
	CEdit msgList;
}StateInfo;
if(xml.FindChildElem(_T("MsgList")))
{
	int x = _tstoi(xml.GetChildAttrib(_T("x")));
	int y = _tstoi(xml.GetChildAttrib(_T("y")));
	int width = _tstoi(xml.GetChildAttrib(_T("width")));
	int height = _tstoi(xml.GetChildAttrib(_T("height")));
	CRect rc;
	rc.top = y;
	rc.left = x;
	rc.right = rc.left + width;
	rc.bottom = rc.top + height;
	m_pStateInfo->msgList.Create(WS_CHILD | WS_VISIBLE | 		 WS_BORDER | ES_MULTILINE | WS_VSCROLL | WS_TABSTOP | ES_LEFT,
		rc,
		this,
		nStartID + i);
	m_pStateInfo->msgList.EnableWindow(TRUE);
}
void CSimulationDlg::ShowInfo(CString str)
{
	CTime curTime;
	curTime = CTime::GetCurrentTime();
	CString c_s;
	c_s = curTime.Format(_T("[%c]"));
	str = c_s + str + _T("\r\n");
	int nLen = m_pStateInfo->msgList.GetLineCount();
	if(nLen > 1000)
	{
		m_pStateInfo->msgList.Clear();
		m_pStateInfo->msgList.SetWindowText(_T(""));
	}
	else
	{
		m_pStateInfo->msgList.SetFocus();
		m_pStateInfo->msgList.ReplaceSel(str);
	}
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值