Guest User

Untitled

a guest
May 26th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. procedure Tuiwin.Copy1Click(Sender: TObject);
  2. var
  3. lv:tlistview;
  4. i,j,b,cols,items,x,len,newLen,margin:integer;
  5. str:string;
  6. arr1:array of array of string;
  7. tempList:tstringlist;
  8. begin
  9. if strClipboard = '' then
  10. begin
  11.  
  12. if focusItem is TListView then
  13. begin
  14. tempList := tstringlist.create;
  15. lv := TListView(focusItem);
  16. cols := lv.Columns.Count;
  17. str := '';
  18. items := 0;
  19. x := 1;
  20. margin := 4;
  21.  
  22. for i := 0 to lv.Items.Count -1 do
  23. if lv.Items[i].Selected then inc(items);
  24.  
  25. SetLength(arr1,items+1,cols); //prepare array
  26.  
  27. for i := 0 to lv.Columns.Count -1 do
  28. arr1[0][i] := lv.Columns[i].Caption;
  29.  
  30. for j := 0 to lv.items.Count - 1 do
  31. begin
  32. if lv.Items[j].Selected then
  33. begin
  34. arr1[x][0] := lv.Items.Item[j].Caption;
  35. for b := 0 to lv.Columns.Count -2 do
  36. begin
  37. arr1[x][b+1] := lv.Items.Item[j].SubItems[b];
  38. end;
  39. inc(x);
  40. end;
  41. end;
  42.  
  43. //determine the longest string length
  44. for i := 0 to length(arr1[0]) -1 do
  45. begin
  46. len := 0;
  47. for j := 0 to length(arr1) - 1 do
  48. begin
  49. newLen := length(arr1[j][i]);
  50. if newLen > len then len := NewLen;
  51. end;
  52. tempList.Add(inttostr(len))
  53. end;
  54.  
  55. for i := 0 to length(arr1[0]) - 1 do
  56. str := str + FillBlankSpace(LengthDifference(arr1[0][i],strtoint(tempList.Strings[i])),' ') + arr1[0][i] + FillBlankSpace(margin,' ');
  57.  
  58. str := str + #13#10;
  59.  
  60. for i := 1 to length(arr1) - 1 do
  61. begin
  62. for j := 0 to length(arr1[0]) - 1 do
  63. begin
  64. str := str + FillBlankSpace(LengthDifference(arr1[i][j],strtoint(tempList.Strings[j])),' ') + arr1[i][j] + FillBlankSpace(margin,' ');
  65. end;
  66. str := str + #13#10;
  67. end;
  68. strClipboard := str;
  69. tempList.free;
  70. end;
  71. end;
  72.  
  73. //send text to clipboard
  74. clipboard.AsText := strClipboard;
  75.  
  76. strClipboard := '';
  77. end;
Add Comment
Please, Sign In to add comment