Forum > Packages and Libraries
TMemo send to bottom or top
eldonfsr:
Hi sorry for topic i trying to play with Tmemo send by code to top or bottom but i don't see event like that caretpos don't show cursor there there another way to do king of movement on Tmemo...
KodeZwerg:
I never tried but according to https://lazarus-ccr.sourceforge.io/docs/lcl/stdctrls/tcustomedit.caretpos.html you might be able to do something like this?
--- 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.CaretPos := 0; // jump to beginningMemo1.CaretPos := Length(Memo.Text); // jump to end
eldonfsr:
Thanks but is not possible Tmemo.carretpos required Tpoint....
Arioch:
so what?
make TPoint variable, assign its fields, and then assign memo's caretpos
but WHAT do you really want to do? http://xyproblem.info/
do you want to move caret (mere position of where user's keying new letters into memo would have the new text inserted) ? or scroll visible text?
MarkMLl:
--- Quote from: eldonfsr on September 27, 2022, 04:28:14 pm ---Thanks but is not possible Tmemo.carretpos required Tpoint....
--- End quote ---
Well give it a TPoint then. I don't know.
This working example might help:
--- 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";}};} ---(* Append a line to the memo being use for status output, scrolling etc. as appropriate.*)procedure TGuiTestForm.StatusAppendLine(const s: string); const limit= 8192; slop= 128; const hasBeenVisible: boolean= false; (* Static variable *) var caret: TPoint; trimmedLines: integer; forceToEnd: boolean; begin with MemoStatus do begin (* Slightly simplified from Watchxxx, *) if Visible then (* idea is to keep the line the user *) hasBeenVisible := true; (* is trying to look at visible. *) if hasBeenVisible then (* Avoid "GetCaretPos called without handle" *) caret := CaretPos else begin caret.X := 0; caret.Y := 0 end; trimmedLines := Lines.Count; (* Visible for debugging *) forceToEnd := caret.Y >= trimmedLines - 1; trimmedLines := 0; try if Lines.Count > limit + slop div 2 then begin while Lines.Count > limit - slop div 2 do begin Lines.Delete(0); trimmedLines += 1; if caret.Y > 0 then caret.Y -= 1 end end; Lines.Append(s); finally if forceToEnd then if Lines.Count > 0 then caret.Y := Lines.Count - 1; if hasBeenVisible then (* Avoid "SetCaretPos called without handle" *) CaretPos := caret end endend { TGuiTestForm.StatusAppendLine } ;
MarkMLl
Navigation
[0] Message Index
[#] Next page