📄 subject_39278.htm
字号:
<p>
序号:39278 发表者:土土 发表日期:2003-05-09 13:58:45
<br>主题:关于CEdit::GetLine()函数
<br>内容:m_receive是编辑框控件的CString类型成员变量,m_crec是编辑框控件的CEdit类型成员变量)<BR>m_receive="abcdefghij";<BR>char* ch=new char[30];<BR> CString str;<BR> int len=m_crec.GetLine(0,ch);<BR> for(int i=0;i<5;i++)<BR> str+=ch[i];<BR> m_receive=m_receive+"\r\n"+str;<BR> UpdateData(false); <BR><BR>为什么得不到正确结果
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:土土 回复日期:2003-05-09 14:32:28
<br>内容:刚刚照着eqiaotea说的,能实现了但是还是有些问题想不明白<BR><BR><BR>void CDlgAppDlg::OnButton1() <BR>{ m_receive = "abcdefghij";<BR> //UpdateData(false);<BR> char* ch=new char[30];<BR> CString str;<BR> int len = m_crec.GetLine(0,ch,30);<BR> for(int j=0;j<5;j++)<BR> str+=ch[j];<BR> m_receive = m_receive+"\r\n"+str;<BR> UpdateData(false);// 奇怪,我如果照上按一下按键显示 abcdefghij 再按就显示两行 abcdefghij<BR> abcde<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:maorachow 回复日期:2003-05-09 14:44:54
<br>内容:m_receive="abcdefghij";<BR>LPTSTR ch=new TCHAR[30];<BR> CString str;<BR> int len=m_crec.GetLine(0,ch,30-sizeof(TCHAR)-2);<BR><BR> for(int i=0;i<9;i++)<BR> str+=ch[i];<BR> m_receive=m_receive+"\r\n"+str;<BR> UpdateData(false);<BR>注意CEdit::GetLine的第三参数是最多可截取的byte个数.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:土土 回复日期:2003-05-09 14:58:28
<br>内容:哦<BR><BR>不过照上面你说的为什么还是得按两次键才能出现正确结果
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小不点 回复日期:2003-05-09 15:03:02
<br>内容:m_receive="abcdefghij";<BR>UpdateData(false); <BR>char* ch=new char[30];<BR>CString str;<BR>int len=m_crec.GetLine(0,ch,30);<BR>for(int i=0;i<5;i++)<BR> str+=ch[i];<BR>m_receive=m_receive+"\r\n"+str;<BR>UpdateData(false); <BR>这样能得到你的正确结果
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:土土 回复日期:2003-05-09 15:20:12
<br>内容: m_receive="abcdefghij";<BR> UpdateData(false); <BR> char* ch=new char[30];<BR> CString str;<BR> int len=m_crec.GetLine(0,ch,30);<BR> for(int i=0;i<sizeof(ch);i++)<BR> str+=ch[i];<BR> m_receive=m_receive+"\r\n"+str;<BR> UpdateData(false);<BR>为什么是这种结果?????
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:土土 回复日期:2003-05-09 15:38:41
<br>内容:根据maorachow说的,也只能取到i为止,那我要取整个一行怎么办啊?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:北极乞丐 回复日期:2003-05-09 15:39:03
<br>内容:奇怪,我用刚才给你的代码试了,按了N(N>=10)下也没有出现不正常的情况啊.<BR>我看了你的图,怎么没发现另外一个Edit box ?<BR>你不是有两个吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:土土 回复日期:2003-05-09 15:46:46
<br>内容:我用的是一个Edit box,不会是因为这个问题引起的吧,请指教!!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:北极乞丐 回复日期:2003-05-09 15:58:43
<br>内容:一个box那怎么有m_receive 然后又有 m_crec?<BR>要取整行只需将:<BR>for(int i=0;i<sizeof(ch);i++)<BR> str+=ch[i];<BR>改成:<BR>str += ch;<BR>即可.<BR>那你的数据是怎么读取的?那个edit box是对应那个?<BR>我的附图有我测试的结果,你看看.<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小不点 回复日期:2003-05-09 16:01:55
<br>内容:给你源代码!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:北极乞丐 回复日期:2003-05-09 16:15:44
<br>内容:你这个程序是什么意思?<BR>无论在里面输入什么得到的结果只有:<BR>abcdefghij<BR>abcdefghij<BR><BR>我猜这不是程序的本意吧.<BR>请土土同志说说你这个程序的目的?以及希望得到的结果.<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:北极乞丐 回复日期:2003-05-09 16:30:24
<br>内容:你再试试这段代码:)<BR>void CGetLineDlg::OnButton1() <BR>{<BR> // TODO: Add your control notification handler code here <BR> char* ch = new char[30];<BR> memset (ch,0,30);<BR> CString str ;<BR><BR> m_crec.GetLine(0,ch,30);<BR><BR> for ( int i=0 ; i<5 ; i++ )<BR> {<BR> str += ch[i];<BR> }<BR> m_receive = "abcdefghij" ;<BR><BR> m_receive = m_receive+"\r\n"+str;<BR><BR> UpdateData (false); <BR><BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:土土 回复日期:2003-05-09 16:45:27
<br>内容:大哥上面我是随便练习GetLine()这个函数的,因为练习时感到很蹊跷,所以请教大哥呢!!<BR> <BR> 能再说说这个:int CharFromPos( CPoint pt )怎么处理吗?主要就是参数的问题
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:北极乞丐 回复日期:2003-05-09 17:01:15
<br>内容:自己看看MSDN的解释吧..:)<BR><BR>int CharFromPos( CPoint pt ) const; <BR><BR>pt :Specifies the coordinates of a point in the client area of this CEdit object<BR><BR>Return Value:<BR>The character index in the low-order WORD, and the line index in the high-order WORD.<BR><BR>Example:<BR>#ifdef _DEBUG<BR> // The pointer to my edit.<BR> extern CEdit* pmyEdit;<BR> // The point where the user clicked the mouse.<BR> extern CPoint myPt;<BR><BR> int n = pmyEdit->CharFromPos(myPt);<BR> int nLineIndex = HIWORD(n);<BR> int nCharIndex = LOWORD(n);<BR> TRACE(TEXT("nLineIndex = %d, nCharIndex = %d\r\n"), nLineIndex, nCharIndex);<BR>#endif<BR><BR><BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -