Forum > LCL
TMemo scroll down (stupid question alert)
Weiss:
there must be some simple command or property in TMemo which would keep last line at bottom of TMemo. Currently when memo window is filled with lines, new lines are populated below the visible window. I added scroll bar and tried different options and properties, like
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---memOutPut.ScrollBy(14,14); with each added line, but kind of did not make difference. I noticed there is an integer "top" in scrollbar.position, so I can do
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---scrollbar.position:=top;
..but I need "bottom". Or any other way to keep last line visible. This is an outPut "readOnly" window. Must be something trivial.
MarkMLl:
It's non-trivial. I don't claim to have an immediate answer to your specific problem, but if you look at https://forum.lazarus.freepascal.org/index.php/topic,67337.msg519191.html#msg519191 you'll find code which appends e.g. status lines to a TMemo or TRichMemo without forcing a scroll for a minute or so.
MarkMLl
jamie:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Sendmessage(Memo1.Handle, EM_LINESCROLL, 0,32767);
hcoenen:
memo1.caretpos:=point(0,memo1.lines.count-1) ?
Weiss:
--- Quote from: hcoenen on October 08, 2024, 01:27:58 am ---memo1.caretpos:=point(0,memo1.lines.count-1) ?
--- End quote ---
you would think. And I thought so too, but no. Caret position will be set, yes, this part works. But memo still shows first line at top and new lines added right were caret position is, at the bottom, outside the window.
Interesting, right? My input memo, where I enter commands, old lines slide up and out of the window, while new lines I enter are always visible at the bottom. Something keeps the new line being entered within a visible part of memo. Here in the forum post window, it works in the same manner. But when new line not entered from keyboard but added
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---memo1.Lines.Add(outputString)it does not.
I am still studying Mark's example
Navigation
[0] Message Index
[#] Next page