Solved

Paste format from Clipboard

Posted on 2000-04-13
8
211 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When I am typing into a TEdit last word repeats 7 134
Performance of SQL statement 37 111
Firemonkey DbLookupComboBox equivalent ? 2 47
Delphi: making a BW image transparent 10 38
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 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