Solved

Paste format from Clipboard

Posted on 2000-04-13
8
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2711254
for jaymol,

#13 - carriage return
#10 - line feed

meikl
0
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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