Solved

Paste format from Clipboard

Posted on 2000-04-13
8
209 Views
Last Modified: 2010-04-04
I try to copy some text from listview
to clipboard, following is my code:

procedure TForm1.MyListView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  Item: TListItem;
  I,Count: Integer;
  S: String;
begin
  if Shift = [ssCtrl] then
  begin
    case Key of
      Ord('C'):
        with myListView1 do
          if SelCount > 0 then
          begin
            Count := SelCount;
            S := '';
            I := 0;
            while (I < Items.Count) and (Count > 0) do
            begin
              Item := Items[I];
              if Item.Selected then
              begin
                S := S + Item.SubItems.Strings[3] + #13 +Item.SubItems.Strings[2] + #13
                     +Item.SubItems.Strings[0] + #13 +Item.SubItems.Strings[1]+ #13 + #13;
                Dec(Count);
              end;
              Inc(I);
            end;
            Clipboard.AsText := S;
          end;
end;


The problem is when I try to paste it from clipborad to notepad, all #13 should be a in seperate line, but it come out some strange character, not in
a seperate line, how to solve it?
(paste to wordpad is OK).

Thanks

Shekou
0
Comment
Question by:shekou
8 Comments
 
LVL 2

Expert Comment

by:mahara
ID: 2711190
i've copied your code and pasted it to
notepad without #13 replacements.

i've pasted it into editpad and other programs.

So where are you copyin' the text from?
0
 
LVL 6

Accepted Solution

by:
Jaymol earned 50 total points
ID: 2711245
Replace the #13 with #10+#13

#10 says - Hey, here's a character that does stuff!!!  What does it do?

Microsoft use it before most "normal" character codes.  (Always worth a try.)

John.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2711247
same result as mahara :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2711254
for jaymol,

#13 - carriage return
#10 - line feed

meikl
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:Jaymol
ID: 2711280
Have you tried it????  I have given the correct answer.

We are talking MicroSoft, not ASCII.  

John.
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2711733
Just in order to complete this:

1) DOS and Windows use #10#13 to describe a new line start

2) Unix/Linux use #10 and

3) Macintosh uses #13.

Most of the text editors under Windows can handle #10#13 or #10 alone but not #13 alone.

Ciao, Mike
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 2711739
Agreed.

Thanks Mike.
0
 

Author Comment

by:shekou
ID: 2715478
Thank both of you, I tried Jaymol's answer, still same problem,
But I think may be it because I am using
Chinese version,  so Jaymol may be right. I give points to him.
I get it work at last, i modified code as following, it works fine:
procedure TForm1.MyListView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  Item: TListItem;
  I,Count: Integer;
  s1: tstringlist;
begin
  if Shift = [ssCtrl] then
  begin
    case Key of
      Ord('C'):
        with myListView1 do
          if SelCount > 0 then
          begin
            Count := SelCount;
            s1:= tstringlist.create;
            I := 0;
            while (I < Items.Count) and (Count > 0) do
            begin
              Item := Items[I];
              if Item.Selected then
              begin
                s1.Add(Item.SubItems.Strings[3]);
                s1.Add(Item.SubItems.Strings[2]);
                s1.Add(Item.SubItems.Strings[0]);
                s1.Add(Item.SubItems.Strings[1]);
                s1.Add('');
                Dec(Count);
              end;
              Inc(I);
            end;
            Clipboard.AsText := S1.Text;
          end;
end;


Thanks

Shekou
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now