windows api中居然没有这一个功能(30分)

  • 主题发起人 主题发起人 我爱PASCAL
  • 开始时间 开始时间

我爱PASCAL

Unregistered / Unconfirmed
GUEST, unregistred user!
SendMessage(handle, EM_GETSEL, 0, i);<br>只能得到所选文本的起始位置,<br>没有得到所选文本的消息.
 
你终于快做到了,继续努力[:D]
 
看不明白
 
EM_GETSELTEXT,搜索一下Delphi源码。
 
在delphi的windows sdk帮助中找到EM_GETSELTEXT,但在delphi中不能识别,为什么.
 
The EM_GETSELTEXT message retrieves the currently selected text in a rich edit control.<br><br>EM_GETSELTEXT &nbsp;<br>wParam = 0; <br>lParam = (LPARAM) (LPSTR) lpBuf; <br> <br><br>Parameters<br><br>lpBuf<br><br>Pointer to a buffer that receives the selected text. The calling application must ensure that the buffer is large enough to hold the selected text.<br><br> <br><br>Return Values<br><br>Returns the number of characters copied, not including the terminating null character.<br>这个是一个RICH EDIT组件的取得内容的消息,VCL好像已经封装。取得选择的内容,DELPHI也有详细的例子。<br>procedure TFrmMain.RichEdit1SelectionChange(Sender: TObject);<br>begin<br><br>end;
 
The EM_GETSELTEXT message retrieves the currently selected text in a rich edit control.<br><br>这个消息只有RichEdit才会响应,普通Edit不行的.<br><br>n application sends an EM_GETSEL message to get the starting and ending character positions of the current selection in an edit control. <br><br>EM_GETSEL &nbsp;<br>wParam = (WPARAM) (LPDWORD) lpdwStart; // receives starting position <br>lParam = (LPARAM) (LPDWORD) lpdwEnd; &nbsp; // receives ending position <br>这个消息可以取到起止位置,并不是只能取起始位置.
 
我试了一下:use richedit就可以用em_getseltext了,<br>请大家看下我这段代码有何问题<br>var<br> &nbsp;num: integer;<br> &nbsp;buffer: array[1..1024*1024] of char;<br> &nbsp;str: string;<br>begin<br> &nbsp; &nbsp;num := SendMessage(f3, EM_GETSELTEXT, 0, longint(@buffer));<br> &nbsp; &nbsp;str := string(buffer);<br> &nbsp; &nbsp;showmessage(str );<br> &nbsp; &nbsp;str := str + str;<br> &nbsp; &nbsp;SendMessage(f3, EM_REPLACESEL, 1, longint(@str));<br>end;
 

Similar threads

D
回复
0
查看
930
DelphiTeacher的专栏
D
D
回复
0
查看
867
DelphiTeacher的专栏
D
D
回复
0
查看
871
DelphiTeacher的专栏
D
D
回复
0
查看
836
DelphiTeacher的专栏
D
D
回复
0
查看
777
DelphiTeacher的专栏
D
后退
顶部