[SOLVED]OnShowhint with dymanic hints lazarus / 21-General ---------------------------------------------------------------------- torbente · 2021-01-17 12:00 I believe i solved this issue some time ago, but i searched the forums and i do not found nothing. I want be able to show a customized hint for a control, which may include even global variables values.For this example lets use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MyButton:= TButton.Create(form1);MyButton.ShowHint := true; I know i must declare a function to be called on show hint: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MyButton.OnShowHint := CheckForHint(MyButton); and then... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure CheckForHint(Sender:TObject);Beginif Sender = MyButton then   begin   // do verifications and finally   MyButton.Hint := 'This is the customized hint';   end;if Sender = AnotherControl // and so on...end; But i got this error: Quoteunit1.pas(37,21) Error: Incompatible types: got "untyped" expected " How i could solve this? ---------------------------------------------------------------------- wp · 2021-01-17 12:34 Quote from: torbente on January 17, 2021, 01:00:31 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MyButton.OnShowHint := CheckForHint(MyButton); This is probably supposed to be Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // if you use {$mode objfpc}MyButton.OnShowHint := @CheckForHint; // or, if you use {$mode Delphi}MyButton.OnShowHint := CheckForHint; ---------------------------------------------------------------------- lucamar · 2021-01-17 13:41 Besides what wp said, there are two other problems; the first is that the signature of your procedure doesn't reflect the one of the event. Note that the event is declared as a TControlShowHintEvent, which is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type TControlShowHintEvent = procedure(    Sender: TObject;    HintInfo: PHintInfo) of object;so your procedure should be: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure CheckForHint(Sender:TObject; HintInfo: PHintInfo); The second is that it's declared "of object", so to be compatible your procedure should be an object's method, for example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.CheckForHint(Sender:TObject; HintInfo: PHintInfo);of course, with the corresponding declaration inside the form's class, in the interface section. That's basically it. HTH! ---------------------------------------------------------------------- torbente · 2021-01-18 03:16 EDIT: Solved using onMouseEnter instead onShowHint Ok, i did it way and everything is ok except that the assigned hint is show the next time the cursor moves over the control. This is what is doing: first show the current hint then run CheckForhint procedure And finally assigns the new hints. So i need something like "BeforeShowHint? Quote from: lucamar on January 17, 2021, 02:41:09 pmBesides what wp said, there are two other problems; the first is that the signature of your procedure doesn't reflect the one of the event. Note that the event is declared as a TControlShowHintEvent, which is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type TControlShowHintEvent = procedure(    Sender: TObject;    HintInfo: PHintInfo) of object;so your procedure should be: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure CheckForHint(Sender:TObject; HintInfo: PHintInfo); The second is that it's declared "of object", so to be compatible your procedure should be an object's method, for example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.CheckForHint(Sender:TObject; HintInfo: PHintInfo);of course, with the corresponding declaration inside the form's class, in the interface section. That's basically it. HTH!