⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_30576.htm

📁 vc
💻 HTM
字号:
<p>
序号:30576 发表者:mmvr 发表日期:2003-02-24 18:11:08
<br>主题:请帮我看看这个richeditctrl的问题
<br>内容:一个richeditctrl类,内有text如下:<BR>LT = action<BR>NT = corrective action<BR><BR>LT = activities<BR><BR>LT = activity<BR>NT = audit<BR>NT = procedure<BR>NT = review<BR><BR>LT = assembler<BR>BT = supplier<BR><BR>LT = audit<BR>BT = activity<BR>BT = reviews<BR>NT = audit finding<BR>NT = audit report<BR><BR>LT = audit client<BR>BT = organization<BR>NT = audit client report<BR><BR>LT = audit client report<BR>BT = audit client<BR>NT = audit client report test<BR><BR>LT = audit client report test<BR>BT = audit client report<BR><BR>LT = audit finding<BR>BT = audit<BR><BR>LT = audit report<BR>BT = audit<BR><BR>LT = audit review<BR>BT = review<BR><BR>LT = audit team<BR>BT = auditor<BR>NT = audit team report<BR><BR>LT = audit team report<BR>BT = audit team<BR>......<BR><BR>输入字符串,如果LT=“输入字符串”就滚动到相应的位置。代码如下:<BR>int CRichEditProxy::ScrollToSelected(CString keyword,int currentline )<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString Line;<BR>&nbsp;&nbsp;&nbsp;&nbsp;char buffer[128];<BR>&nbsp;&nbsp;&nbsp;&nbsp;int linetojump;<BR>&nbsp;&nbsp;&nbsp;&nbsp;int totalLine=m_predit-&gt;GetLineCount();<BR>&nbsp;&nbsp;&nbsp;&nbsp;for (int i=0;i&lt;totalLine;i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_predit-&gt;GetLine(i,buffer);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line=buffer;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Line.Left(2)=="LT" &amp;&amp; Line.Find(keyword)!=-1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;linetojump=i-currentline;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_predit-&gt;LineScroll(linetojump);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currentline=i;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;return currentline;<BR>}<BR>现在的问题出在m_predit-&gt;GetLine(i,buffer)这句,每当读入空行(只有回车的行),下一行的返回值就不正确,请高手帮忙看看是怎么回事?<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:不说 回复日期:2003-02-26 05:00:53
<br>内容:仔细看看MSDN哈,有这么两个地方:<BR>1)首先这个GetLine有俩原型,一个俩参数的,一个仨参数,你用的是俩参数的,MSDN如是说:The first word of the buffer must specify the maximum number of bytes that can be copied into the buffer,所以你这么直接GetLine(i, buffer)肯定是不对的。<BR>2)MSDN里还有这么一句:The copied line does not contain a terminating null character。说明啥呢,每循环一次你得把这个buffer清一次0,或者根据返回值就从buffer里读这么多个字节出来。<BR><BR>建议哈,一个是用GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength),一个是每循环一次都ZeroMemory一哈。逻辑上有没有其他错误俺就不看了哈
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:mmvr 回复日期:2003-02-26 18:16:16
<br>内容:问题解决了,多谢了!<BR>不过开始我是碰到回车行下一行就读2遍,也可以解决问题(因为每行开头一般是N、B或L,ascii码肯定大于每行的长度,而空行首字‘\n’的ascii值是10,所以下一行一般读不完),现在我换成3参数的函数了,肯定不会出问题了。<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-02-26 19:15:02
<br>内容:倒……<BR><BR>是PS2上的《真三国无双2》赫赫……不过其实走的不严重,俺分析多半是贴图错误赫赫……
<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 + -