Forum > LCL
[SOLVED] TRichMemo and text colour
cdbc:
Hi
Nice, good on you Mark.
--- Quote ---Hoping that is useful to somebody.
--- End quote ---
It is, Thanks :)
Regards Benny
MarkMLl:
I've edited that example function I provided with a couple more internal error checks, and to use the memo's .Tag property for a seconds timeout so that if the user has scrolled (and set the cursor) to look at an older message it will revert to displaying newly-appended messages after 2:30. That originally used a static variable (initialised constant), but that's obviously NBG if multiple memos are being used.
MarkMLl
cdbc:
Hi
Nifty little solution, Me Likey ;)
Regards Benny
MarkMLl:
--- Quote from: cdbc on June 05, 2024, 10:07:49 am ---Hi
Nifty little solution, Me Likey ;)
Regards Benny
--- End quote ---
It appears that system colours like clGrayText can't be used in this context, although that might depend on the widget set.
I've added a term to force the tag's LSB to 1 which will reduce the risk it could be confused with a reference to an object.
MarkMLl
CM630:
I tried to modify AddRichText.
I have an issue with ABackgroundColour = clDefault - I cannot get the actual colour of the RichMemo.
The ARichMemo.Colour returns clDefault.
I tried with Brush, etc, I still do not get the actual background colour of the RichMemo. Any ideas?
--- 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";}};} ---procedure AddRichText(ARichMemo: TRichMemo; const AText: string; const AForegroundColour: TColor = clDefault; const ABackgroundColour: TColor = clDefault);var StartPos, EndPos: Integer; FontParams: TFontParams;begin StartPos := ARichMemo.SelStart; EndPos := StartPos + Length(AText); FontParams.Color := AForegroundColour; FontParams.HasBkClr := True; if ABackgroundColour = clDefault then FontParams.BkColor := clWhite //I do not know how to handle this else FontParams.BkColor := ABackgroundColour; FontParams.Name := Graphics.GetFontData(ARichMemo.Font.Handle).Name; FontParams.Size := Round((- Graphics.GetFontData(ARichMemo.Font.Handle).Height * 72 / ARichMemo.Font.PixelsPerInch)); FontParams.Style := Graphics.GetFontData(ARichMemo.Font.Handle).Style; FontParams.VScriptPos := vpNormal; ... end;
Navigation
[0] Message Index
[#] Next page
[*] Previous page