为了账号安全,请及时绑定邮箱和手机立即绑定

VS 2017 C++中,添加CEdit自定义变量,编译报错无法读取内存,该怎样添加CEdit变量?

VS 2017 C++中,添加CEdit自定义变量,编译报错无法读取内存,该怎样添加CEdit变量?

C++
慕无忌2961384 2018-04-27 08:53:58
void CDeletethespecifiedcharacter151Dlg::OnBnClickedButton1(){ // TODO: 在此添加控件通知处理程序代码 CString strtxt, str1, str2, strres; int istart, iend; CEdit m_text;//此处添加的m_text变量 m_text.GetWindowText(strtxt);//此处添加的m_text变量 m_text.GetSel(istart, iend);//此处添加的m_text变量,程序报错无法读取内存,该怎样添加CEdit 变量? if (istart==iend) { return; }; str1 = strtxt.Left(istart); if (iend>=strtxt.GetLength()) { str2 = ""; } else { str2 = strtxt.Right(strtxt.GetLength()-iend); } strres += str1; strres += str2; m_text.SetWindowText(strres);}
查看完整描述

1 回答

?
慕无忌2961384

TA贡献2条经验 获得超0个赞

https://img1.sycdn.imooc.com//5ae284e4000104bf19201080.jpg

void CDeletethespecifiedcharacter151Dlg::OnBnClickedButton1(){	// TODO: 在此添加控件通知处理程序代码	CString strtxt, str1, str2, strres;	int istart, iend;		m_text.GetWindowText(strtxt);	m_text.GetSel(istart, iend);	if (istart==iend)	{		return;	};	str1 = strtxt.Left(istart);	if (iend>=strtxt.GetLength())	{		str2 = "";	}	else	{		str2 = strtxt.Right(strtxt.GetLength()-iend);	}	strres += str1;	strres += str2;	m_text.SetWindowText(strres);}


查看完整回答
反对 回复 2018-04-27
?
慕无忌2961384

TA贡献2条经验 获得超0个赞

小白学VC 2017 C++,今天练习一个MFC对话框程序“在文本中删除指定的汉字或句子”,首先创建对话框后,添加了BUTTON和EDit-control控件,然后在类向导添加了自定义类型为CEdit类型的变量m_text,给BUTTON添加事件绑定代码如下,然后在调试器中编译,当输入文字删除光标选中的文字时,程序异常终止,在m_text.GetSel(istart,iend)遭遇断点,请各位大大帮我看看怎么回事。。

查看完整回答
反对 回复 2018-04-27
  • 1 回答
  • 2 关注
  • 3376 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信