Working with text

Hello everybody,
I am working with two richedit and what I need to do is:

The first richedit there is a scrambled phrase like:  "Someone in working that a company big man with was morning yesterday"

The correct order is: "Someone was working in that big company with a man yesterday morning"

A phrase will appear to be assembled on the correct order in the second richedit, the first richedit will get the scrambled word, after a click, the selected word will be cast in the second richedit in order. step by step until it be finished, each clicked work from richedit 1 must disappear and appear in the second richedit.

If I click someone, so "someone" goes to richedit2 and if I click "was" goes too, assembling the correct order:

someone was ... so on

PS: I am working with Rxrichedit that has the event on DblClick

How could I do something like that?

Thanks
Alexandre
LVL 1
hidrauAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
well, not perfect yet,
but do you mean something like this?

unit re_swap_words_u;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, RxRichEd;

type
  TForm1 = class(TForm)
    RxRichEdit1: TRxRichEdit;
    RxRichEdit2: TRxRichEdit;
    procedure RxRichEdit1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses richedit; //Richedit-Unit is used

{$R *.DFM}

procedure TForm1.RxRichEdit1DblClick(Sender: TObject);
var
  cPos : LongInt;  //PosFromChar
  WStart, WLen : Integer;
  OldSelLen,       //Remember Current
  OldSelStart : Integer;
  P : TPoint;
  CR : TCharRange;
begin
  //get MouseCoords
  GetCursorPos(P);
  //Transform into relativ to Control
  P := RxRichEdit1.ScreenToClient(P);
  cPos := LoWord(RxRichEdit1.Perform(EM_CHARFROMPOS,0,DWord(@P)));  //Get the CharIndex
  WStart := RxRichEdit1.Perform(EM_FINDWORDBREAK,WB_Left,CPos);     //Get Left WordBreak
  WLen := RxRichEdit1.Perform(EM_FINDWORDBREAK,WB_Right,CPos) - WStart -1;  //Get Length of Word
  RxRichedit1.Perform(EM_HIDESELECTION,1,0);  //disable Showing of selection
  OldSelStart := RxRichedit1.SelStart;        //Select the Word
  OldSelLen := RxRichedit1.SelLength;
  RxRichedit1.SelStart := WStart;
  RxRichEdit1.SelLength := WLen;
  //Prepare Target
  RxRichedit2.Selstart := length(RxRichEdit2.Text);
  RxRichedit2.SelLength := 0;
  RxRichedit2.SelText := ' '+RxRichedit1.SelText;  //add the text
  RxRichedit1.SelText := '';  //Remove the Text
  RxRichEdit1.SelStart := OldSelStart;      //Back to Current
  RxRichedit1.SelLength := OldSelLen;
end;


end.

meikl ;-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hidrauAuthor Commented:
Hello kretzschmar
Thanks for you help,
I made something too and I would like you to take a look in my last post after this.
I am going to close this giving the points to you.

Only the words must go to the second ritchedit, without any return carrier chr(10) or chr(13)

Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.