-

   rss_forum_sources_ru

 - e-mail

 

 -

 LiveInternet.ru:
: 29.07.2007
:
:
: 80

:


RichEdit ?

, 25 2021 . 19:07 +
VladFS: .
.
, . , EM_GETCHARFORMAT, , .

. TRichEdit, Jv, cx .
RichEdit1.SelStart:=i; , RichEdit1.SelLength:=1; 1 . , 3, 1 . - .
, yOffset: " EM_GETCHARFORMAT CHARFORMAT ( CHARFORMAT2 RE 2.0) yOffset. - . - . - ."
dwMask CFM_OFFSet (" yOffset, CFM_OFFSet DWMask". , ).
, - CHARFORMAT2. - , . , ?
Word' - RichEdit1.
Delphi 10.4.

:
    unit Unit1;
    interface
    uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, RichEdit;
    type
    TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    RichEdit2: TRichEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;
    var
    Form1: TForm1;
    implementation
    {$R *.dfm}
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    RichEdit1.Clear;
    RichEdit2.Clear;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var i:integer; S1,S2,S3,S4:string;
    CF:TCharFormat;
    begin
    for i:=1 to 5 do begin //
    RichEdit1.SelStart:=i; //
    RichEdit1.SelLength:=1; // 1 ( , - 1 )
    S1:=RichEdit1.Text[i]; //
    S2:=S2+RichEdit1.Text[i]; //
    FillChar(CF, SizeOf(CF), 0); //FillChar - ,
    CF.cbSize:=SizeOf(CF); //cbSize - , , . , rich edit control, CBSIze CHARFORMAT CHARFORMAT2. CBSIze CharFormat, CharFormat. (https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-charformat2w_1)
    CF.dwMask:=CFM_OFFSet; //dwMask - CHARFORMAT2, . DWMask . , . Dweffects. (https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-charformat2w_1)
    // yOffset, CFM_OFFSet DWMask (//https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-charformat2w_1)
    RichEdit1.Perform(EM_GETCHARFORMAT, SCF_SELECTION, LPARAM(@CF)); //Perform - (Windows message)
    if CF.yOffset >0 then // , ...
    begin
    S3:=S3+RichEdit1.Text[i]; //
    end;
    if CF.yOffset <0 then // , ...
    begin
    S4:=S4+RichEdit1.Text[i]; //
    end;
    end;
    RichEdit2.Lines.Add(': '+S3);
    RichEdit2.Lines.Add(': '+S4);
    end;
    end.

https://forum.sources.ru/index.php?showtopic=421824&view=findpost&p=3849691

:  

: [1] []
 

:
: 

: ( )

:

  URL