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?

Comments

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

    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);
    var
      ht: TLMDDockSiteHitTest;
      ch: TLMDDockZone;
      p: TPoint;
    begin
      if HintInfo.HintControl = Site then
      begin
        p  := Site.ScreenToClient(Mouse.CursorPos);
        ht := Site.GetHitTest(p);

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

    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:
    http://stackoverflow.com/a/15031957/127670
Sign In or Register to comment.