如何更改RichEdit控件中的字符间距?
我曾尝试使用CHARFORMAT结构,但正如MSDN所说,sSpacing在RichEdit控制中是无用的。此外,SetTextExtra函数在该控件的hdc中也是无用的。
并尝试使用该控件的ole接口,ITextFont接口的SetSpace函数,效果不佳。
有人能帮我吗?
谢谢!
发布于 2012-06-08 22:07:07
如果您指的是单个字符之间的字符间距,我不确定您是否可以做些什么。如果您正在讨论行之间的间距,那么请使用PARAFORMAT结构和EM_SETPARAFORMAT消息。
发布于 2019-03-29 07:03:45
绝对可以在Windows10中使用RichEdit v8.5。
确保您使用的是Windows类"RICHEDIT50W" (来自MsftEdit.dll),而不是"RichEdit20W"类(来自Riched32.dll):
//Get the ITextDocument interface of the RichEdit control
IUnknown re;
if (SendMessage(RichEdit1.Handle, EM_GetOleInterface, 0, ref (LPARAM)re) == 0)
throw new Exception("Could not get ITextDocument from RichEdit");
ITextDocument doc = re as ITextDocument;
//Increase spacing (positive is expanded)
Single spacing = doc.Selection.Font.Spacing;
spacing += 1;
doc.Selection.Font.Spacing = spacing;
//Decrease spacing (negative is compressed)
spacing = doc.Selection.Font.Spacing;
spacing -= 1;
doc.Selection.Font.Spacing = spacing;
//Reset to normal spacing
doc.Selection.Font.Spacing = 0;

https://stackoverflow.com/questions/10949400
复制相似问题