惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
博客园 - Franky
Martin Fowler
Martin Fowler
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
The Cloudflare Blog
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享
J
Java Code Geeks
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
MongoDB | Blog
MongoDB | Blog
腾讯CDC
博客园_首页
博客园 - 司徒正美
D
DataBreaches.Net
I
InfoQ
GbyAI
GbyAI
IT之家
IT之家
罗磊的独立博客

博客园 - 涂磊

TMS可以单独安装控件 02]AdvStringGrid中添加CheckBox 01]TMSadvStringGrid下载与安装 epson投影仪提示,保存时间的电池电量偏低,取消显示 用DeepSeek做的Delphi闹钟 XboxS联网下载完游戏后,要拔掉网线,就能玩游戏了 12]RichEdit某些文本突出显示 delphi10.3中Tmemo中某些文本显示下划线 delphi的TReeView支持鼠标拖动节点 cnPack里MarkDown里RTF显示 11]delphi中 RichEdit1设置行距 10]RichEdit另存 为BMP图片 09]delphi中richedit查找 08]delphi10.3剪贴板的图片,保存到文件 07]Delphi10.3中Richedit中的链接可以点击 06]delphi10.3中richedit中文本背景颜色 05]delphi10.3中richedit中删除线 delphi10.3中UpDown1使用 03]RichEdit插入BMP图片 delphi 中tButtonColor颜色选择 02]如何设置RichEdit文本颜色?_编程语言-CSDN问答 01]delphi从TRichEdit获得RTF格式文本(PC版本) Delphi10.3接收从文件管理器拖放过来的文件名
04]RichEdit的上标和下标,Delphi10.3
涂磊 · 2026-02-16 · via 博客园 - 涂磊
uses   Winapi.RichEdit;
// yOffset values
type

 TCharacterFormat = (CFM_Superscript, CFM_Subscript, CFM_Normal);
procedure RE_SetCharFormat(RichEdit: TRichEdit; CharacterFormat: TCharacterFormat);
//=======================================
procedure RE_SetCharFormat(RichEdit: TRichEdit; CharacterFormat: TCharacterFormat);
var
 // The CHARFORMAT structure contains information about
 // character formatting in a rich edit control.
 Format: TCharFormat;
begin
 FillChar(Format, SizeOf(Format), 0);

 with Format do
 begin

   cbSize := SizeOf(Format);
   dwMask := CFM_OFFSET;
   // Character offset, in twips, from the baseline.
   // If the value of this member is positive,
   // the character is a superscript;
   // if it is negative, the character is a subscript.
   case CharacterFormat of
     CFM_Superscript: yOffset :=  250;    //上标偏移值
     CFM_Subscript: yOffset   := -250;    //下标偏移值
     CFM_Normal: yOffset := 0;
   end;

 end;
 // The EM_SETCHARFORMAT message sets character formatting in a rich edit control.
 // SCF_SELECTION: Applies the formatting to the current selection
 Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));

end;
procedure TMainForm.ToolButton7Click(Sender: TObject);
begin
RE_SetCharFormat(Editor, CFM_Superscript);    //上标
end;

procedure TMainForm.ToolButton8Click(Sender: TObject);
begin
RE_SetCharFormat(Editor, CFM_Subscript);   //下标
end;

image

image