TstatusBar OnHint not called unless AutoHint is checked But! lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2017-10-03 01:52 The OnHint event does not get called if I don't check mark the AutoHint property..   However, the hint I set in the HintText still auto shows when I hover over it if I set the ShowHint to true, but no OnHint event is called.  This is with Laz 1.6.4 32bit IDE ,windows  So  is a it a bug or bad documentation ? BTW, I have 2 panels allocated at the moment. ---------------------------------------------------------------------- BlueIcaro · 2017-10-03 09:13 Hi, did you put false in ParentShowHint property? /BlueIcaro ---------------------------------------------------------------------- jamie · 2017-10-03 21:32 ParentShowHint is false.  the ShowHint works as it should when I Set it, it shows the actual hint I have in the hint text but it just does not  trigger the OnHint event Like I said.   Need to use AutoHint for the event to work.  What I do is test the mouse over in that event and find out which panel I am over and then change the Hint.Text for that specific panel.  I used a BEEP test for verification. ---------------------------------------------------------------------- wp · 2017-10-03 23:25 Quote from: jamie on October 03, 2017, 11:32:36 pm What I do is test the mouse over in that event and find out which panel I am over and then change the Hint.Text for that specific panel. This sentence gives me the feeling that you want to show different hints for various controls/panels and that you try to achieve this by modifying the OnHint event. The intended way to achieve this to assign an individual hint text to the Hint property of each panel and leave the event alone. You can even specify different texts for popup hint and statusbar hint by separating them with a | character in the Hint property. 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 Panel1.Hint := 'Popup hint for panel 1|This is the statusbar hint of panel 1.';Panel2.Hint := 'Hint for both popup and statusbar'; I do notice that this does not work if a handler is assigned to the statusbar's OnHint. If you want the hint to change while moving the mouse across the same control you can hook into the OnMouseMove event of the control: 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.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);begin  if X < Panel1.Width div 2 then begin    Panel1.Hint := 'Popup hint for Panel1/left half';    Application.Hint := 'Statusbar hint for Panel1/left half';    Panel1.Caption := Format('X = %d, left', [x]);  end else begin    Panel1.Hint := 'Popup hint for Panel1/right half';    Application.Hint := 'Statusbar hint for Panel1/right half';    Panel1.Caption := Format('X = %d, right', [x]);  end;  Application.CancelHint;  Application.ActivateHint(Mouse.CursorPos);end; ---------------------------------------------------------------------- jamie · 2017-10-04 00:18 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 TDesign.StatusBar1Hint(Sender: TObject); var   P:TPoint;   X:Integer; begin   P := Mouse.CursorPos;   P:= StatusBar1.ScreenToClient(P);   X := statusbar1.GetPanelIndexAt(P.X,P.Y);   if X <> -1 Then   Case X of    0:StatusBar1.Hint := 'X,Y'+#13+'Pixels';    1:StatusBar1.Hint := 'X,Y'+#13+MetricString[Ord(TheLabel.LayOutInfo.Metric)];    Else      StatusBar1.Hint := '';   end; end; ---------------------------------------------------------------------- jamie · 2017-10-04 00:20 I can seem to get pasting in a code window working here but.. The last post shows what I am doing with the OnHint Handler so  I can assign different hints.   Btw.     I don't have any HINT property on the TStatusPanel in my edition of Laz.. ---------------------------------------------------------------------- Remy Lebeau · 2017-10-05 00:57 Quote from: jamie on October 04, 2017, 02:18:58 amCode: 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 TDesign.StatusBar1Hint(Sender: TObject);var  P:TPoint;  X:Integer;begin  P := Mouse.CursorPos;  P:= StatusBar1.ScreenToClient(P);  X := statusbar1.GetPanelIndexAt(P.X,P.Y);  if X <> -1 Then  Case X of   0:StatusBar1.Hint := 'X,Y'+#13+'Pixels';   1:StatusBar1.Hint := 'X,Y'+#13+MetricString[Ord(TheLabel.LayOutInfo.Metric)];   Else     StatusBar1.Hint := '';  end;end; In Delphi, I would use the VCL's TApplication.OnShowHint event for that, as it is the official way to sub-divide a control into multiple hint areas (or, you can subclass a control to handle the VCL's CM_HINTSHOW message) eg: 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 TMyForm.FormCreate(Sender: TObject);begin  // or, use a TApplicationEvents component instead...  Application.OnShowHint := ApplicationShowHint;end; procedure TMyForm.FormDestroy(Sender: TObject);begin  Application.OnShowHint := nil;end; procedure TMyForm.ApplicationShowHint(var HintStr: string;  var CanShow: Boolean; var HintInfo: THintInfo);var  I, X: Integer;  R: TRect;begin  if HintInfo.HintControl = StatusBar1 then  begin    X := -1;    for I := 0 to StatusBar1.Panels.Count-1 do    begin      SendMessage(StatusBar1.Handle, SB_GETRECT, I, LPARAM(@R));      if PtInRect(R, HintInfo.CursorPos) then      begin        X := I;        Break;      end;    end;    case X of      0: HintStr := ...;      1: HintStr := ...;    else      HintStr := '';      Exit;    end;    HintInfo.CursorRect := R;  end;end; FreePascal/Lazarus also has a similar TApplication.OnShowHint event, so try something like this: 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 TDesign.ApplicationShowHint(var HintStr: string;  var CanShow: Boolean; var HintInfo: THintInfo);var  X: Integer;  R: TRect;begin  if HintInfo.HintControl = StatusBar1 then  begin    X := StatusBar1.GetPanelIndexAt(HintInfo.CursorPos.X, HintInfo.CursorPos.Y);    case X of      0: HintStr := ...;      1: HintStr := ...;    else      HintStr := '';      Exit;    end;    // manually calculate client rect of TStatusPanel at index X, as    // TStatusBar and TStatusPanel don't have a method for that..    R := ...;     HintInfo.CursorRect := R;   end;end;