Recent

Author Topic: Unnecessary scrollbar - TMemo  (Read 3748 times)

mrstarware

  • New member
  • *
  • Posts: 7
Unnecessary scrollbar - TMemo
« on: December 28, 2011, 07:39:58 pm »
Hi, I'm working on a program that uses TMemo boxes. They need to be able to scroll, however, I only want the scroll bars to appear if the content does not fit the box. Other than some sort of internal coding such getting the number of lines or the length of the longest line how can I set up autoscroll? It appears that the ssAuto feature makes the vertical scrollbar appear (inactive) regardless.

Thanks,

Trevor

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Unnecessary scrollbar - TMemo
« Reply #1 on: December 30, 2011, 01:41:57 am »
Interesting - you are correct.

From what I can tell by looking at many other applications, the default behavior for the vertical scroll bar is to always be shown but to be inactive until the row count is larger than the window. 

If you want to change that behavior, just create a simple event that checks every time a line is added to the tMemo with something like ...
if large
  then tMemo.Scrollbar := ssAutoBoth
  else tMemo.Scrollbar := ssAutoHorizontal;

Zoran

  • Hero Member
  • *****
  • Posts: 1980
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Unnecessary scrollbar - TMemo
« Reply #2 on: December 30, 2011, 05:54:00 am »
Interesting - you are correct.

From what I can tell by looking at many other applications, the default behavior for the vertical scroll bar is to always be shown but to be inactive until the row count is larger than the window. 

It is so if Memo.WordWrap is True. If WordWrap is False, then both scrollbars are always shown.
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

 

TinyPortal © 2005-2018