Recent

Author Topic: How to make a watermarked Memo?  (Read 1274 times)

loaded

  • Hero Member
  • *****
  • Posts: 859
How to make a watermarked Memo?
« on: March 18, 2024, 09:17:42 am »
Hi All,
I have a form with multiple memos. In terms of visuality, I want to add watermark to these memos. It may look similar to the view in the example.
Is this possible ?
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: How to make a watermarked Memo?
« Reply #1 on: March 18, 2024, 10:04:55 am »
Problem is that TMemo doesn't have Paint or Canvas.

You could use PaintTo or TControlCanvas over TMemo but you would need to update it each time TMemo updates/repaints itself.

Small example with buttonpress.

Code: Pascal  [Select][+][-]
  1. procedure AngleTextOut(ACanvas: TCanvas; Angle, X, Y: Integer; Text: string);
  2. var
  3.   NewFontHandle,
  4.   OldFontHandle: hFont;
  5.   LogRec       : TLogFont;
  6. begin
  7.   GetObject(ACanvas.Font.Handle, SizeOf(LogRec), Addr(LogRec));
  8.   LogRec.lfEscapement := Angle * 10;
  9.   LogRec.lfOrientation := LogRec.lfEscapement;
  10.   NewFontHandle := CreateFontIndirect(LogRec);
  11.   OldFontHandle := SelectObject(ACanvas.Handle, NewFontHandle);
  12.   ACanvas.TextOut(X, Y, Text);
  13.   NewFontHandle := SelectObject(ACanvas.Handle, OldFontHandle);
  14.   DeleteObject(NewFontHandle);
  15. end;
  16.  
  17. procedure TForm1.Button1Click(Sender: TObject);
  18. var
  19.   AC: TControlCanvas;
  20. begin
  21.   AC := TControlCanvas.Create;
  22.   try
  23.     AC.Control := Memo1;
  24.     AC.Brush.Style:=bsClear; // transparent
  25.     AC.Font.Name := 'Arial';
  26.     AC.Font.Color := clGray;
  27.     AC.Font.Size := 60;
  28.     AngleTextOut(AC, 45, 10, 180, 'Header');
  29.   finally
  30.     AC.Free;
  31.   end;
  32. end;

Maybe someone can come up with a better idea  ;)

loaded

  • Hero Member
  • *****
  • Posts: 859
Re: How to make a watermarked Memo?
« Reply #2 on: March 18, 2024, 11:39:36 am »
I would like to thank you as much as the number of characters in your answer, rvk.
Yes, this could be a solution, but it has some problems, the most obvious of which is;
The watermark remains on the text.
If a more minimal and trouble-free solution does not come up, I will try to use this. But for now, as you said;
Maybe someone can come up with a better idea  ;)
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

RayoGlauco

  • Full Member
  • ***
  • Posts: 196
  • Beers: 1567
Re: How to make a watermarked Memo?
« Reply #3 on: March 18, 2024, 01:09:29 pm »
Here is a similiar question, with its solution, for Delphi. Maybe it can inspire you:
https://stackoverflow.com/questions/55899526/how-to-draw-a-colored-line-to-the-left-of-a-tmemo-which-looks-like-a-gutter
To err is human, but to really mess things up, you need a computer.

rvk

  • Hero Member
  • *****
  • Posts: 6693
Re: How to make a watermarked Memo?
« Reply #4 on: March 18, 2024, 01:14:38 pm »
I already tried to make TMemo transparent but that doesn't work (like it does in Delphi).

With TRichMemo it does (it also has a Transparent property).
With TSynEdit there should also be multiple possibilities (because it has a Paint event and otherwise could also be made transparent).

But the TMemo has serious limitations in Lazarus (maybe due to the cross-platform capabilities).

jamie

  • Hero Member
  • *****
  • Posts: 6834
Re: How to make a watermarked Memo?
« Reply #5 on: March 18, 2024, 01:17:09 pm »
For windows a transparent panel overlay
The only true wisdom is knowing you know nothing

loaded

  • Hero Member
  • *****
  • Posts: 859
Re: How to make a watermarked Memo?
« Reply #6 on: March 18, 2024, 08:37:24 pm »
RayoGlauco and jamie, thank you very much for your answers.
It scared me that the situation had become so complicated. As I mentioned above, I only wanted this for visuality.

But the TMemo has serious limitations in Lazarus (maybe due to the cross-platform capabilities).
I think you're right, I'll stick to using text tags for now.  ;D
Respects.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018