delphi - 如何从 TRichedit 中按点或按索引获取字符

标签 delphi char position message richedit

我有返回字符索引的函数 GetCharFromPos(Pt: TPoint): Integer;

现在我想了解该职位的特征。像 GetCharByIndex(Index: Integer): Char;

最佳答案

使用纯 VCL 实现此目的的有效方法是使用 SelStartSelLengthSelText

function GetCharByIndex(Index: Integer): Char;
begin    
  RichEdit.SelStart := Index;
  RichEdit.SelLength := 1;
  Result := RichEdit.SelText[1];
end;

您可能希望在修改之前保存选择,然后在读取字符后恢复它。

<小时/>

然而,这是一种相当困惑的读取字符的方式。如果您准备使用原始 Win32 API,那么您可以使用 EM_GETTEXTRANGE .

关于delphi - 如何从 TRichedit 中按点或按索引获取字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6263562/

相关文章:

delphi - 恢复为设计时的TImage图片

delphi - TVirtualStringTree 搜索结果高亮

java - 搜索字符数组列出某个字符

CSS 问题 : overflow:hidden child div position:absolute not working?

html - div 在另一个 div 中(css 定位)

delphi - 从内部 .dll 获取模块句柄

database - 如何使用 dbExpress 和 Delphi(也可能是 DataSnap)来抽象我的业务模型?

将 int 转换为 char* C

java - 在数组中查找 Char,如果不存在则添加到新的 String 数组中

html - 拉伸(stretch) block 元素以填充其父元素的 100% 垂直滚动高度