سؤال

أواجه بعض المشكلات مع Trichedit.

المشكلة الأولى هي إذا حاولت لصق الكثير من النص من الحافظة إلى Trichedit فارغة، فقد اقتطاع الجزء السفلي من النص.

المشكلة الثانية، التي أعتقد أن العلاقات في المشكلة الأولى، هو أنه يبدو أنني أقتصر على عدد الأحرف التي يمكن أن تعرضها trichedit، وبالتالي لصق الحافظة تخسر بعض البيانات.

إذا قمت بلصق TJVRICHEDIT (JEDI)، فإن ذلك يعمل بشكل جيد، من الواضح أن هذا مكون مختلف تماما.

في هذه اللحظة في الوقت المناسب، أود الحصول على حل ل TrichEdit لأنني أستخدم الكثير من الإجراءات / الوظائف وما إلى ذلك، إذا قمت بالتغيير إلى فئة تحرير غنية مختلفة، فسوف يتعين علي تحرير الكثير من التعليمات البرمجية الخاصة بي للعمل .

في الأساس ما أسأله هو:

  • هل هناك حد في trichedit؟ الذي أنا متأكد من وجوده.
  • كيف يمكنني زيادة الحد من trichedit لقبول المزيد من الشخصيات والخطوط وما إلى ذلك.

    يرجى تقديم المشورة / الحل ل Trichedit فقط.

    تحرير

    لم يعثر على الإجابة باستخدام: giveacodicetagpre.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top