1

Is it possible to make TMemo show partially visible lines? I'm looking for a native way to do that, without custom rendering.

I made an example screenshot for those who not familiar with this issue:

MemoPartialVisibilityExample

As you can see,, in the area I marked with red, there is enough space to display some part of the next line that is not visible by default.

There are some components, like TListBox, which show partially visible lines, so I want to make TMemo do the same.

P.S. I'm not interested in other suggestions, like enlarging the TMemo size, that's off-topic.

Michael
  • 41,989
  • 11
  • 82
  • 128
Markus_13
  • 328
  • 2
  • 14
  • 1
    How would you display partially visible lines? They're partially visible because there's not enough room to fully display them. Please [edit] your question to make it more clear what you're asking, because what you've asked here makes no sense. – Ken White Feb 28 '17 at 23:04
  • Set the scrollbars visible, then you can scroll to make them visible. Alternatively you can navigate in the memo with the arrow keys for instance. – Sertac Akyuz Feb 28 '17 at 23:16
  • My question is already clear, i want Memo show partially visible lines, which are not visible by default. What else i can add?? – Markus_13 Feb 28 '17 at 23:21
  • Alternatively you can enlarge the memo to make the contents fit. – Sertac Akyuz Feb 28 '17 at 23:22
  • Added screenshot. And few other explanations. – Markus_13 Feb 28 '17 at 23:34
  • No, a suggestion to enlarge the memo is not *offtopic*. It may be something you don't want to accept, but the standard TMemo does not display partial lines, so you can either make the memo slightly larger (to display the line) or smaller (to not display the empty space). Those are the only choices you have. A memo is not a combobox or listbox, and MS did not design it to show partial lines of text. A listbox or combobox also supports custom drawing of its items, while a memo does not (because it doesn't have items to draw). – Ken White Feb 28 '17 at 23:48
  • If Memo's size will be changed to leave no empty space there will no be any possibility to show partially visible lines, so it is an offtopic. I didn't asked how to make Memo size proportional to it's line height... – Markus_13 Feb 28 '17 at 23:54
  • 4
    Honestly, I'm not sure why all the down-votes here. This is a perfectly legitimate question. OP has a problem, which is clearly stated, and at least I understand it clearly. Even an example of desired behavior is in the question. Just because "that's by design" is technically the answer, doesn't mean the question isn't valid, or useful, or well-thought. – Jerry Dodge Mar 01 '17 at 03:01
  • Also, I wouldn't accept an answer of "it's not possible". Surely custom-drawing is an option. Sure, it may be a bit overhaul, but just because that's a bit of extra work doesn't mean it's not an option. Actually, whenever I'm putting together a project plan, and am putting together basic options, I tend to add even the extreme options which will obviously never be chosen. Only for perspective. For example, one option's title was "Re-write entire software to abide by third-party API rules". Clearly would never be chosen, but is still possible. – Jerry Dodge Mar 01 '17 at 03:06
  • 1
    @Jerry: TMemo does not support custom drawing, so an answer of *it's not possible* is correct. If your suggestion is to develop an entirely new control not based on TMemo to accomplish this, that's fine, but it does not change the fact that TMemo (or the underlying Windows edit control) does not support it. – Ken White Mar 01 '17 at 04:01
  • @Ken Indeed. But just the fact that `TMemo` doesn't support custom drawing doesn't mean OP is unable to accomplish desired results. While that's reason enough to close and not be able to answer, I don't see how that's reason to down-vote. However, since my comments, I did realize that the question was originally poorly asked, and then edited with more info later. – Jerry Dodge Mar 01 '17 at 04:09
  • @Jerry Question explicitly names TMemo. Substituting a different control isn't permitted. – David Heffernan Mar 01 '17 at 06:02
  • 1
    Why do you guys always take every little word so literally and use it against me on everything I say? Jeez, no wonder people hate this site. – Jerry Dodge Mar 01 '17 at 06:16
  • @Jerry We're programmers. We take things literally. If you mean one thing but say another, don't be surprised if we take you at your word. – David Heffernan Mar 01 '17 at 18:12
  • Good question!! Have an upvote! Anyone found a way to do this yet (with a TMemo, a hacked TMemo, or some other component, seeing as we're programmers here? (With apologies to @DavidHeffernan)) – Reversed Engineer Jun 23 '17 at 14:40
  • @DaveBoltman, lot of time has passed and i have no sources at my hands atm, but i clearly remember that it could be done with some WinAPI hook and manual EM_SETRECTNP messages (and maybe something more, can't remember the whole process). Tho the thing is that it's not efficient comparing to component-switch solution (e.g. RichEdit). – Markus_13 Aug 23 '17 at 17:39

2 Answers2

2

It's not possible to make a TMemo to show partial lines. For what you can do natively to a memo, which is a multiline edit control, see edit controls on MSDN.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
0

You could use a TRichEdit instead.

You can access the Lines and Text properties, just like for a TMemo. It also has the WordWrap, ReadOnly and ScrollBars properties, just like TMemo, so it could be a drop-in replacement, but showing partial lines at the bottom as required.

Tested in Delphi 10.1 Berlin as well.

enter image description here

Reversed Engineer
  • 1,095
  • 13
  • 26