Copy MS Word content to TRichviewEdit

General TRichView support forum. Please post your questions here
Post Reply
King Cheung
Posts: 12
Joined: Fri Mar 23, 2012 2:08 am

Copy MS Word content to TRichviewEdit

Post by King Cheung »

I'm trying to copy content from MS Word and paste it to TRichviewEdit. In the OnPaste event, my code like this:

Code: Select all

 str := Clipboard.AsText;
 rchvwdt.InsertTextA(str,False);
 DoDefault := false;
In this way, what i get is plain text without font info. What should i do to get text with font info?
King Cheung
Posts: 12
Joined: Fri Mar 23, 2012 2:08 am

Post by King Cheung »

Cause the pasted content mostly chinese,if i dont't add the OnPaste function, their will be some error.For example, if i copy "(有无)"from Ms Word, after i paste it to richviewedit, it will be "(无".
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Why do you need to process OnPaste? TRichViewEdit can paste the content saved by MS Word automatically, without any additional code.
King Cheung
Posts: 12
Joined: Fri Mar 23, 2012 2:08 am

Post by King Cheung »

Sergey Tkachenko wrote:Why do you need to process OnPaste? TRichViewEdit can paste the content saved by MS Word automatically, without any additional code.
When i copy chinese from Ms Word to TRichViewEdit,sometimes it will be wrong.You can try it, when copy "(有无)" from MS Word to TRichViewEdit, the result will be "(无".
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What version of Delphi do you use?
Please give me step by step instructions how to reproduce this problem.
Send the source doc file to richviewgmailcom
King Cheung
Posts: 12
Joined: Fri Mar 23, 2012 2:08 am

Post by King Cheung »

Sergey Tkachenko wrote:What version of Delphi do you use?
Please give me step by step instructions how to reproduce this problem.
Send the source doc file to richviewgmailcom
I am using Delphi 7, and the richview version is v11.0.5.FS.AS we need to paste chinese to TRichViewEdit,so unicode is the only choice.Then i add some code like this:

Code: Select all

 rchvwdt.Clear;
  for i:= 0 to rvstyl.TextStyles.Count-1 do
    rvstyl.TextStyles[i].Unicode := True;

  rchvwdt.RTFReadProperties.UnicodeMode := rvruOnlyUnicode;
I will send you a chinese test doc, you can copy the text and paste it to TRichViewEdit,then it will cause the error.
King Cheung
Posts: 12
Joined: Fri Mar 23, 2012 2:08 am

Post by King Cheung »

Sergey Tkachenko wrote:What version of Delphi do you use?
Please give me step by step instructions how to reproduce this problem.
Send the source doc file to richviewgmailcom
Hello Sergey,
Do you test the chinese text? I really look forward to your solution!Thank you!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I tested you file - copied it from MS Word to TRichViewEdit, and it looks exactly the same.
You use an old version of TRichView, please update it and test if this problem still exists.
King Cheung
Posts: 12
Joined: Fri Mar 23, 2012 2:08 am

Post by King Cheung »

Sergey Tkachenko wrote:I tested you file - copied it from MS Word to TRichViewEdit, and it looks exactly the same.
You use an old version of TRichView, please update it and test if this problem still exists.
Hello Sergey,
The problem is solved after i update the TRichView. Thank you!
Post Reply