Forum > LCL

Problem with Hints

<< < (2/3) > >>

lainz:
Can you add a custom drawn hint?

Or use THintWindow as suggested...

jamie:
Have you looked at the Trunk or maybe the 4.0CR has it, the Tshape has extra features.

One of them is "ptInshape" and also you can assign your custom shape

As for the Hint issue, I think it's best to not use the HINTS in the shapes but the global one where you can examine the shape control and using the "PtInShape" feature to test the overlaid shapes.

Jamie

Sieben:
Where, I suppose,


--- Quote from: jamie on December 03, 2024, 11:16:18 pm --- the global one
--- End quote ---

refers to Application.OnShowHint which at design time can be accessed via TApplicationProperties.

simsee:
Thanks for your answers. I had thought about custom drawn hint, but due of my laziness I preferred to look for alternatives on the forum.

I didn't know THintWindow and it seems to me that it is the best solution for my case.

But I don't understand how to position the hints correctly. For example in ActivateHint method, to which origin are the coordinates referred? Thanks.

Alexandr R:
see links on the topic:
'membership of a point to a closed figure"
https://habr.com/ru/articles/301102/;
https://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/;
https://algolist.ru/maths/geom/belong/poly2d.php.

The THintWindow module can be used 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";}};} ---unit msg_Hint; {$mode ObjFPC}{$H+} interface uses  Classes, SysUtils, LazUtf8, Forms, Controls; type TMsgHint = Class(THintWindow)  public   constructor Create(aOwner: TComponent); override;   destructor  Destroy; override;   {Устанавливает над компонентом aControl Нint c c сообщением aMsg. Внимание:    компонент aControl должен иметь родителя.                                  }   procedure SetScope(aControl: TControl; aMsg: string); end; implementation constructor TMsgHint.Create(aOwner: TComponent);begin inherited Create(aOwner); Self.HideInterval:= 4000; //время показа сообщения 4с. Self.AutoHide:= True; Self.Color     := $00B3FFFF; //слоновая кость Self.Font.Color:= $000404FF; //красно-коричневый Self.Alignment:= taRightJustify;end; destructor  TMsgHint.Destroy;begin inherited Destroy;end; procedure TMsgHint.SetScope(aControl: TControl; aMsg: string);var Rect : TRect; pnt  : TPoint;begin Rect:= Self.CalcHintRect(0, aMsg, nil); if aControl.Width> Rect.Right then  Rect.Right:= aControl.Width; pnt:= aControl.ClientOrigin; Rect.Left:= pnt.X-2;             Rect.Top   := pnt.Y-Rect.Bottom; Rect.Right:= pnt.X+Rect.Right-2; Rect.Bottom:= pnt.Y; Self.ActivateHint(Rect, aMsg);end; end.  

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version