Pregunta

Estoy teniendo algunos problemas con el trichedit.

El primer problema es si intento pegar un montón de texto desde el portapapeles en un tricedit vacío, trunca la parte inferior del texto.

El segundo problema, que supongo que los lazos en el primer problema, es que parezco limitado a la cantidad de caracteres que puede mostrar el trichedit, por lo que pegar desde el portapapeles está perdiendo algunos de los datos.

Si me pego en un tjvrichedit (Jedi), que funciona bien, obviamente porque ese es un componente completamente diferente.

En este momento, en el tiempo, me gustaría una solución para el tricedit porque estoy usando muchos procedimientos / funciones, etc., si cambio a una clase de edición enriquecida diferente, tendré que editar mucho de mi código para trabajar .

Básicamente lo que estoy preguntando es:

  • ¿Hay un límite en el trichedit? que estoy seguro de que hay.
  • ¿Cómo puedo aumentar el límite del trichedit para aceptar más personajes y líneas, etc.

    Por favor, proporcione asesoramiento / solución para Trichedit solamente.

    editar

    No me importan la respuesta usando:

    RichEdit11.MaxLength := $7FFFFFF0;
    

¿Fue útil?

Solución

Quoting an answer given by David Pate from the newsgroups:

The following remarks apply to the versions of Delphi that use the Windows Richedit version 1 control. I understand that this includes all Delphi versions prior to version 7. (I do not know what the situation is when you run programs compiled in these versions on the various NT/2000 versions of Windows although Windows XP behaves as described.)

Q. What is the limit to the amount of text that a Richedit can hold? A. The help files (Delphi help and Win32 SDK) are confusing, contradictory and incorrect on this point. There are 5 limits to be considered

  1. The Maximum Capacity: the "hard-wired" limit, i.e the maximum size of the RichEdit's text buffer. It is 2 bytes less than 2 Gb. Note that this is the theoretical limit; in practice the limit will be determined by your computer's memory.

  2. The Capacity: the actual size of the current buffer. By default, it is 64Kb but can be resized by several means.

  3. The "Keyboard limit": the limit beyond which characters cannot be added by typing from the keyboard. It is often different from the Capacity but, like the Capacity, it is by default, 64Kb and can be resized by several means.

  4. The MaxLength property of the tRichEdit object. The default of 0 sets both the Capacity and "Keyboard limit" to 64Kb.

  5. The line-number limit: theoretically this is around 134 million, but in practice, you can expect to get much less than this. The maximum number of lines seems to depend on several factors including the amount of memory available and the average length of the lines. I find that I can get around 150 thousand to 200 thousand lines. Note also that it has been reported that some releases of the Windows 95 Richedit control sometimes throw an exception when more than a few hundred lines are added. This appears to be due to a bug in the control and to have been corrected in later releases..

Q. How can I increase the amount of text that a tRichEdit can hold?

A. When you add text programmatically, both the Capacity and the "Keyboard limit" are resized to accommodate the text being added. By adding text programmatically, I mean using any of the Add, Append, AddStrings or Assign methods of the tRichEdit.Lines property or the LoadFromFile, LoadFromStream or SetTextBuf methods of tRichEdit. Note that adding text in this way does not update the MaxLength property.

B. By using the MaxLength property. This sets the "Keyboard limit" to the value passed to MaxLength. It also increases the Capacity to match the "Keyboard limit" if the existing Capacity is less than MaxLength. Note that you cannot use MaxLength to reduce the Capacity and that changing MaxLength has no effect if the value passed is less than the length of the text currently in the control. To increase the Capacity and the "Keyboard limit" to the same value, set the tRichEdit.MaxLength to the desired value. To set the maximum size in the Object Inspector, use the value 2147483645 ($7FFFFFFD). To set it programmatically it is simpler to use .MaxLength := System.MaxInt-2;. The EM_LIMITTEXT and EM_EXLIMITTEXT messages may also be used to change the "Keyboard limit" and Capacity but I'd not normally recommend using them since, if you do, you will not be updating the MaxLength property.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top