Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure Tuiwin.Copy1Click(Sender: TObject);
- var
- lv:tlistview;
- i,j,b,cols,items,x,len,newLen,margin:integer;
- str:string;
- arr1:array of array of string;
- tempList:tstringlist;
- begin
- if strClipboard = '' then
- begin
- if focusItem is TListView then
- begin
- tempList := tstringlist.create;
- lv := TListView(focusItem);
- cols := lv.Columns.Count;
- str := '';
- items := 0;
- x := 1;
- margin := 4;
- for i := 0 to lv.Items.Count -1 do
- if lv.Items[i].Selected then inc(items);
- SetLength(arr1,items+1,cols); //prepare array
- for i := 0 to lv.Columns.Count -1 do
- arr1[0][i] := lv.Columns[i].Caption;
- for j := 0 to lv.items.Count - 1 do
- begin
- if lv.Items[j].Selected then
- begin
- arr1[x][0] := lv.Items.Item[j].Caption;
- for b := 0 to lv.Columns.Count -2 do
- begin
- arr1[x][b+1] := lv.Items.Item[j].SubItems[b];
- end;
- inc(x);
- end;
- end;
- //determine the longest string length
- for i := 0 to length(arr1[0]) -1 do
- begin
- len := 0;
- for j := 0 to length(arr1) - 1 do
- begin
- newLen := length(arr1[j][i]);
- if newLen > len then len := NewLen;
- end;
- tempList.Add(inttostr(len))
- end;
- for i := 0 to length(arr1[0]) - 1 do
- str := str + FillBlankSpace(LengthDifference(arr1[0][i],strtoint(tempList.Strings[i])),' ') + arr1[0][i] + FillBlankSpace(margin,' ');
- str := str + #13#10;
- for i := 1 to length(arr1) - 1 do
- begin
- for j := 0 to length(arr1[0]) - 1 do
- begin
- str := str + FillBlankSpace(LengthDifference(arr1[i][j],strtoint(tempList.Strings[j])),' ') + arr1[i][j] + FillBlankSpace(margin,' ');
- end;
- str := str + #13#10;
- end;
- strClipboard := str;
- tempList.free;
- end;
- end;
- //send text to clipboard
- clipboard.AsText := strClipboard;
- strClipboard := '';
- end;
Add Comment
Please, Sign In to add comment