有关EM_LINEFROMCHAR(30分)

  • 主题发起人 主题发起人 zhsh
  • 开始时间 开始时间
Z

zhsh

Unregistered / Unconfirmed
GUEST, unregistred user!
如果要判断RichEdit中当前在哪一行,杂志上说可以用em_LineFromChar,<br>该消息的第一个参数WPARAM是what?,能否举例.
 
delphi 4里有属性!
 
EM_LINEFROMCHAR <br>wParam = (WPARAM) ich; &nbsp;// character index <br>lParam = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // not used; must be zero <br><br>Parameters<br>ich <br><br>Value of wParam. Specifies the character index of the character <br>contained in the line whose number is to be retrieved. If the ich <br>parameter is -1, either the line number of the current line <br>(the line containing the caret) is retrieved or, if there is a <br>selection, the line number of the line containing the beginning <br>of the selection is retrieved.
 
打个比方:<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; &nbsp;Inte : Integer;<br>begin<br>&nbsp; &nbsp; &nbsp;Inte := SendMessage( RichEdit1.handle, EM_LINEFROMCHAR, -1, 0 );<br>&nbsp; &nbsp; &nbsp;Memo1.Lines.Add( Format( 'Line:%d',[ Inte ] ) );<br>end;<br>这样就可以在Memo里获得RichEdit1的行数了!
 
茶叶蛋,ich 代表什么,whose number 是指从第一行第一个字符算起,还是别的,<br>我就想知道这个。Delphi的API 帮助让我迷惑
 
ich 应该就是第一个参数的名字吧.<br>......<br>嘻嘻,弄了半天,总算弄清了.<br>它的用法和帮助上说的有点不一样:<br><br>如果ich的值是非负的话,则返回RichEdit里文字的总行数<br>但若总行数大于&lt;font color="ff0000"&gt;[ ich / 2 ]&lt;/font&gt;,则返回[ ich / 2 ].<br>比如:Edit中有20行,若ich = 5,则返回[ 5/2 ]=2,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;若ich= 50,由于[50/2]&gt;20, 则返回20<br><br><br>如果ich的值是负数的话,就返回当前行(光标所在的行)的行数,<br>但如果有选择操作(文字反相显示)的话,则返回所选文字的第一行的行数.<br><br>这条帮助怎么看怎么不通,不过千万不要怪Delphi,她也是从Win32帮助里抄下来的.
 
to get the current line number the caret lies in, uses the following<br>line:<br><br>var LineNumber: Integer;<br>...<br>&nbsp;LineNumber:= Integer(SendMessage(RichEdit1.Handle,EM_LINEFROMCHAR,RichEdit1.Selstart,0));<br><br>because EM_LINEFROMCHAR message returns a LongInt, so we need to typecast<br>it to the integer;<br>
 
最近网太慢。<br>茶叶蛋: 多谢指点。ich&lt;0如你所说,但ich&gt;0时,返回值总为零,不是总行数或是<br>其它。你试过吗?
 
下面是我试过的东东:<br>ich, return_values<br>1 &nbsp; &nbsp; &nbsp; 0 &nbsp;<br>11 &nbsp; &nbsp; &nbsp;1 <br>13 &nbsp; &nbsp; &nbsp;2<br>15 &nbsp; &nbsp; &nbsp;3<br>17 &nbsp; &nbsp; &nbsp;4<br>31 &nbsp; &nbsp; &nbsp;11<br>40 &nbsp; &nbsp; &nbsp;15<br>63 &nbsp; &nbsp; &nbsp;27<br>511 &nbsp; &nbsp; 251 <br>&nbsp; &nbsp; <br>Return_value好像是[ ( ( ich - 10 ) &nbsp;+ 1 ) / 2 ]<br>真不好意思,上次做数学归纳法做错了.<br>
 
茶叶蛋,多谢指点,分数奉上。另在非技术栏上有我关于formdesigner的问题,<br>请阅并指点
 
茶叶蛋,多谢指点,分数奉上。另在非技术栏上有我关于formdesigner的问题,<br>请阅并指点
 

Similar threads

回复
0
查看
976
不得闲
回复
0
查看
1K
不得闲
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
899
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部