Raymond Chen, who has been developing windows for over 25 years, just made fun of the so-called "maximum data limit" bug in the system clipboard in a developer blog of the old new thing** He took a large spreadsheet file with 300000 + rows as an example. When users open it, select all rows and copy them to the clipboard, they will encounter problems when pasting them to another application.
Suppose this application uses get Clipboard Data function to retrieve data in rich text format. Then you will regret to find that the function returned a null value.
Many people may guess that the problem may be related to the upper limit of clipboard data.
However, Raymond Chen points out that this is not the case.
The clipboard is not preset with the maximum value of extractable data, and its contents are limited only by the available memory and address space.
To avoid get Clipboard The data call fails. There are two main alternatives - one is to put the data directly on the clipboard, and the other is to declare that you have a specific type of data without putting it directly on the clipboard.
For data formats that are rarely used or that consume too much resources, the common optimization scheme is to use the clipboard delay rendered.
Then, when asked about the format of the data, the user of the data source will receive a WM_ Renderformat message - if someone wants to call this data, do you choose to generate it immediately?
Raymon Chen Explain that:
Excel itself cannot run in rich text format. Such data placed on the clipboard is obtained by delayed rendering.
Then when another program asks for rich text format data, excel will give such a response - Oh, OK, please wait a moment, and I will help you get it.
It is reported that rich text is not the best format for data tables, because it is mainly designed for text. Even if you can handle simple forms, more complex tasks will not run smoothly.
When the system asks the owner of the clipboard to render data, it sends a message and waits up to 30 seconds to return.
If the data is not generated within 30 seconds, the system will abandon the request and cause getclipboarddata to return a null value.
The problem with this example is that the original table is so large that excel needs more than 30 seconds to generate a rich text format table. The subsequent development team will envisage special means to prolong the waiting time for such processing.