函数在EditBox winApit中获取选定的文本 [英] Function get selected text in EditBox winApit
本文介绍了函数在EditBox winApit中获取选定的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
是否有任何WinAPI可以在编辑框"中获取选定的文本?取光标的初始位置和最终位置?我告诉editbox的HWND的函数,然后函数返回所选择的文本?
Alexandre
Hi
Is there any WinAPI to get the selected text in an Edit Box? Take the initial and final position of the cursor? A function where I tell the HWND of editbox and the function return, the selected text?
Alexandre
推荐答案
首次使用
EM_GETSEL
检索当前选择的开始和结束的字符索引.
对于少量文本的编辑控件,可以使用窗口消息
WM_GETTEXT
检索整个窗口文本并选择它的适当部分.
对于包含大量文本的多行编辑控件,此方法可能效率不高.在这种情况下,您可以使用
EM_GETHANDLE
获取编辑控件使用的缓冲区的内存句柄.使用LocalLock
获取指向该缓冲区的内存指针.然后,您可以直接访问该缓冲区,并使用EM_GETSEL返回的字符索引检索选择的文本.
First use
EM_GETSEL
to retrieve the character indices of the begin and end of the current selection.
For edit controls with small amounts of text you can use the window message
WM_GETTEXT
to retrieve the entire window text and select the appropriate part of it.
For multi-line edit controls with huge amounts of text, this method can be inefficient. In that case you can use
EM_GETHANDLE
to get the memory handle of the buffer that the edit control uses. UseLocalLock
to get a memory pointer to that buffer. Then you can access that buffer directly and retrieve the select text by using the character indices that EM_GETSEL has returned.
这篇关于函数在EditBox winApit中获取选定的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文