at3s 4 Posted October 18, 2020 (edited) I tried in Delphi to make working a C++ sample (Character spacing in RichEdit control) but spacing does not change (doc.Selection.Font.Spacing). I guess, Font.Spacing is deprecated but not sure. Did someone something similar or can confirm it's not possible? Edited October 18, 2020 by at3s Share this post Link to post
FPiette 385 Posted October 18, 2020 Would be nice if you publish the code you have already tried so that we can review it and even try to make it work without having to invent a full test program. Share this post Link to post
at3s 4 Posted October 18, 2020 (edited) 43 minutes ago, FPiette said: Would be nice if you publish the code you have already tried so that we can review it and even try to make it work without having to invent a full test program. Sure. Here is a unit: unit uRichEdit; interface uses System.SysUtils , Winapi.Windows , Vcl.ComCtrls , Winapi.RichEdit , tom_TLB ; type TRichEditHelper = class helper for TRichEdit private class function reGetTextDocument(RichEdit: TRichEdit): ITextDocument; public class function reSpacing(ARichEdit: TRichEdit; ASpaces: Integer): Boolean; end; implementation { TRichEditHelper } class function TRichEditHelper.reGetTextDocument( RichEdit: TRichEdit): ITextDocument; var re: IUnknown; begin if RichEdit.Perform(EM_GETOLEINTERFACE, 0, LParam(@re)) = 0 then begin Result := nil; Exit; end; re._AddRef; if not Supports(re, ITextDocument, Result) then Result := nil; end; class function TRichEditHelper.reSpacing(ARichEdit: TRichEdit; ASpaces: Integer): Boolean; var doc: ITextDocument; spacing: Single; begin doc := reGetTextDocument(ARichEdit); doc.Selection.Start := 0; doc.Selection.End_ := Length(doc.Selection.Text); doc.Selection.Font.Spacing := ASpaces; end; end. and its using: TRichEdit.RichEditSpacing(reSample, 10); You have to import 'tom' type library. Edited October 18, 2020 by at3s Share this post Link to post
Kryvich 165 Posted October 18, 2020 (edited) You need RichEdit50W, but TRichEdit utilize Riched32.dll / Riched20.dll, not MsftEdit.dll. In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files. Edited October 18, 2020 by Kryvich 1 Share this post Link to post
at3s 4 Posted October 18, 2020 58 minutes ago, Kryvich said: You need RichEdit50W, but TRichEdit utilize Riched32.dll, not MsftEdit.dll. In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files. It works in Delphi, thanks a lot. Share this post Link to post
at3s 4 Posted October 23, 2020 Hi again, For some reason, spacing doesn't work on 32-bit Windows 7 and Windows XP, even it works fine on Windows 10 x64. I guess it's because their msftedit.dll file version. Does someone know if it's correct and how to fix this? Share this post Link to post
FPiette 385 Posted October 23, 2020 Maybe a new Win8 or Win10 feature not supported by Win7. Share this post Link to post
at3s 4 Posted October 23, 2020 6 minutes ago, FPiette said: Maybe a new Win8 or Win10 feature not supported by Win7. It seems so. On 10/18/2020 at 7:32 PM, Kryvich said: You need RichEdit50W, but TRichEdit utilize Riched32.dll / Riched20.dll, not MsftEdit.dll. In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files. Does JvRichEdit's Spacing work fine in all Windows versions (Win7 x32, Win XP f.e.)? Share this post Link to post
Kryvich 165 Posted October 23, 2020 (edited) Yes, I see the same. It's strange, because when I generate tom_TLB.pas, even in Windows XP there is Spacing property in ITextFont interface. After doc.Selection.Font.Spacing := ASpaces, the Spacing property is actually returns the new value, but the edit control is not displaying as expected. Edited October 23, 2020 by Kryvich Share this post Link to post
at3s 4 Posted October 24, 2020 20 hours ago, Kryvich said: Yes, I see the same. It's strange, because when I generate tom_TLB.pas, even in Windows XP there is Spacing property in ITextFont interface. After doc.Selection.Font.Spacing := ASpaces, the Spacing property is actually returns the new value, but the edit control is not displaying as expected. Exactly. I even tried to copy and load different MsftEdit.dll versions in Windows 7, but without success. Share this post Link to post
Kryvich 165 Posted October 24, 2020 The fun part is that WordPad, which uses the same Rich Edit control, can display text correctly in Windows 7 (but not in XP). Share this post Link to post