Solved

Paste format from Clipboard

Posted on 2000-04-13
8
215 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

635 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