Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TLMDDockPanel Hint not showing

  panel : TLMDDockPanel;

  panel.Hint     := 'Test hint';
  panel.ShowHint := True;

The hint should show up as a tooltip when I hover the mouse over the panel tab caption but it doesn't. What else do I need to do to make this work?


  • 3 Comments sorted by Votes Date Added
  • Posts: 0 Accepted Answer Vote Up0Vote Down

    There no built-in feature of showing panel's hints on the corresponding tabs. However, you can do this manually. Use OnShowHint event of the TApplicationEvents component, like this:

    procedure TfrmMain.ApplicationEvents1ShowHint(var HintStr: string;
      var CanShow: Boolean; var HintInfo: THintInfo);
      ht: TLMDDockSiteHitTest;
      ch: TLMDDockZone;
      p: TPoint;
      if HintInfo.HintControl = Site then
        p  := Site.ScreenToClient(Mouse.CursorPos);
        ht := Site.GetHitTest(p);

        if (ht.Kind = hkZone) and (ht.ZoneArea = hzaTabs) and
           (ht.Index >= 0) then
          ch := ht.Zone.Tabs[ht.Index].Zone;
          if (ch <> nil) and (ch.Panel <> nil) then
            CanShow := True;
            HintStr := ch.Panel.Caption;
        CanShow := False;

    This code is just an example and it is not perfect. I predict that you will also need some additional code to update hint when mouse moving from one tab to another and to cancel hint in some situations. You can use Site.OnMouseMove event handler and call Application.ActivateHint and Application.CancelHint in required cases.

    PS: We consider to add this feature in the next version.
  • Thank you for that quick answer, and sorry it has taken me so long to respond.

    I found the answer was even easier. There's no need for an OnMouseMove handler. Just set the HintInfo.CursorRect to the bounds of the tab:

      HintStr := ch.Panel.Caption;
      HintInfo.CursorRect := ht.Zone.Tabs[ht.Index].Bounds;

    When the mouse moves outside of that rectangle but is still within the control's client area, the ShowHint event is generated again to obtain new information to update the current hint with. Consequently, the hint disappears as soon as the mouse moves outside of that tab, and changes when the mouse moves to another tab. No messing about with Application.ActivateHint and Application.CancelHint needed.

    See this answer on Stack Overflow:
Sign In or Register to comment.