copy to clipboard

i need to allow copying the content of a list view control (with 2 columns), the problem is that when i paste them on a notepad instead of 2 columns i get one huge line with strange fonts instead of the "new line" charachter.

you have 45000 item with two columns per item you are sending 90000 LVM_GETITEMTEXT to the control ,with the control copying the values back and then you concatenating them , and do you think this shuold not take some time ?

I'm sure you know what you're doing :) but why do you need 45,000 items in the listview? Perhaps it's just for testing (in which case the timing won't be as much of a problem in production), but if not, the user won't be sticking around long enough to find out what's at the bottom.

it takes so long because the string buffer must be reallocated from time to time. Therefore a new, bigger buffer is allocated and the complete string is copied to it. The old buffer is deleted. This takes time.

Solution: calculate or estimate the maximum size and tell it tou your CString-object.

>> what changes do i need to make in order to be able to paste in 2 columns...?

I don't understand your question. Are the columns the problem or the lines ?
You said that the newline makes trouble.
That's because a line usually ends with carriage return PLUS linefeed. You copied only a linefeed to clipboard.

there r 2 columns because they r represent coordinates.
each item is from type float (4 digits after floating point).

ambience & pacman: thanks for the info, i didn't know that "\r" was essential for this matter.

>>but why do you need 45,000 items in the listview?
IainHere: i'm displaying graphs which basically is a spectrum, while each one of the items is a coordinate in the spectrum.
since the graph is editable each coordinate also displayed in the list control, in oredr to allow manual editing.

Pacman: how can i estimate the max size of the full concatenated string?
is it better (or more efficient) to work with short strings instead of one huge string?
how do perform a massive string allocation?

NOTE: the only reason that i need to copy the content of the list control to the clipboard is beacuse there is an engine which perform calculations on this data and run in a web site, this engine know how to read 2 columns of data which represent the coordinates of the spectrum.

"NOTE: the only reason that i need to copy the content of the list control to the clipboard is beacuse
there is an engine which perform calculations on this data and run in a web site, this engine know how
to read 2 columns of data which represent the coordinates of the spectrum."

I don't fully understand the above, so forgive me if this is useless: If you're displaying the info on a graph, why not allow the user to edit the graph using a different (more user friendly?) way, such as clicking on a point and the info for that point (and maybe a few around it) being displayed in a listview / textedit? Surely no-one is prepared to look through 45,000 points to edit the one they're after?

I think you're saying that you need to paste the results into a web page? Would it be better to do that by parsing the information stored in the graph into the string? Do you have any control over the web site?

IainHere:
there's no connection between the web engine which calculate the data from my stand-alone program and the spectrum, since this program is internaly (for the "lab-rats" usage only).
what they did so far is save the results of the spectrum in a text file and copy its content to the right place in the web site for the calculation part.
the copy to clipboard is only for an easy usage.
anyhow, i really appreciate your help but i think i've done with this issue.
i realized that the results of the spectrum is nothing more than 100 peaks tops. which mean that there is no need for massive string allocation and all that stuff.
using CString concatenation is more tan enough.
thanks anyway and keep up the ggood work (and comments)

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms. Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go. MFC has a very cool system for handli…

Introduction:
Dialogs (2) modeless dialog and a worker thread. Handling data shared between threads. Recursive functions.
Continuing from the tenth article about sudoku.
Last article we worked with a modal dialog to help maintain informat…

In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…