Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to copy tstringlist.text to clipboard correctly

483 views
Skip to first unread message

gmc...@21cn.com

unread,
Aug 2, 2006, 7:32:48 AM8/2/06
to
Hi there,
I am using the following code to copy tstringlist.text to the
clipboard

var
cp :TClipboard;
str :PAnsiChar;
begin
...
str := StrList.GetText(); // StrList is TStringList
...
cp := TClipboard.Create;
cp.Open;
cp.SetTextBuf(str);
cp.Close;
end;

If the tstinglist contains Asian Characters, when copy to and paste
from clipboard to NOTEPAD, the Asian characters become meaningless
characters. How can I copy and paste tstringlist.text corretly?

Thanks in advanced.

Message has been deleted

Riki Wiki

unread,
Aug 3, 2006, 1:32:08 AM8/3/06
to
Hoi

You need to repost your message on the Borland news server to make
everybody see it and possibly answer your message.

How to post to Delphi newsgroups:
<http://delphi.wikia.com/wiki/Delphi_Newsgroups>

gmclee

unread,
Aug 3, 2006, 2:51:40 AM8/3/06
to

Kurt Barthelmess [TeamB]

unread,
Aug 3, 2006, 5:37:49 AM8/3/06
to
"gmclee" <gmc...@gmail.com> wrote:

> cp := TClipboard.Create;

Why are you creating a new TClipboard object? When you add Clipbrd to
your uses clause, one is automatically created for you. (See the
Clipboard function.) If there's a reason to use your own instance, you
need to Free that as well - you show no code for that.

> str :PAnsiChar;

ANSIChar's are eight bit characters - not double byte or Unicode. Are
you sure this allows for your "Asian" character set?

> cp.SetTextBuf(str);

This sets the content of str into the clipboard with a CF_TEXT format.
I suspect you need to be using a CF_UNICODETEXT format. See
SetClipboardData in the Windows help.

Good luck.

Kurt

gmclee

unread,
Aug 3, 2006, 5:55:36 AM8/3/06
to

kbarth...@compuserve.com (Kurt Barthelmess [TeamB]) wrote:
>"gmclee" <gmc...@gmail.com> wrote:
>
>> cp := TClipboard.Create;
>
>This sets the content of str into the clipboard with a CF_TEXT format.
>I suspect you need to be using a CF_UNICODETEXT format. See
>SetClipboardData in the Windows help.

Thanks. The issue is all about CF_UNICODETEXT, the problem is solved now.

0 new messages