Re: Popup Hints in Treeview

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 10/07/04


Date: Thu, 7 Oct 2004 16:08:54 +0200


"AlanGLLoyd" <alanglloyd@aol.com> wrote in message
news:20041007060705.24105.00000864@mb-m12.aol.com...
> In article <chc82t$rsj$1@newsreader2.netcologne.de>, Peter Sprenger
> <sprenger@moving-bytes.de> writes:

>> I want to give every item in a treeview a different popup hint.
>
> You have to turn the TreeView.ShowHints off and generate and display
> your own hint window in the TreeView OnMouseMove event handler ...

I do?

<snip very horrible handler>

I did this instead:

event TTreeView.OnMouseMove;
var
  TreeView: TTreeView;
  CurrentNode: TTreeNode;
begin
  if (Sender is TTreeView)
  then TreeView:=Sender as TTreeView
  else Exit;

  CurrentNode:=TreeView.GetNodeAt(X, Y);

  if (Assigned(CurrentNode) and (X<TreeView.Indent*CurrentNode.Level))
  then CurrentNode:=nil;

  if not (HoverNode=CurrentNode)
  then begin
    HoverNode:=CurrentNode;
    Application.CancelHint;
    TreeView.Hint:=ComputeHint(HoverNode);
  end;
end;

Required but not shown are a form field (HoverNode) to keep track of
the node the mouse is (or last was) over, and a function (ComputeHint)
that turns a treenode into the desired hint string. The function can
be written out in-line, of course.

With many thanks to Bruce, who posted the bit about CancelHint at just
the right time to make me look good at work.

Note that the bit about Indent and Level is not required; it just
inhibits hint display when the mouse is visually left of the node
proper.

Groetjes,
Maarten Wiltink



Relevant Pages

  • Re: Javascript form control element validation
    ... want to be able to display a popup window (callout?) when a text input ... is to display a "hint". ... So that when a user clicks in the username cell, they have a "hint" that gives them further info about the field, along with the opton to close the "hint". ...
    (comp.lang.javascript)
  • Re: Does Psalm 110 really work for Big Industry?
    ... >> quoted from other questinable source, and he doesn't display even a ... >> hint of being able to think for himself. ... >> posts and rantings. ...
    (sci.energy.hydrogen)
  • Re: Creating a distribution list
    ... First thank you very much for the hint. ... > Hi Kerstin, ... >> I get a DL where the display name is always the email address. ... >> Set myRecipients = myMailItem.Recipients ...
    (microsoft.public.outlook.program_vba)
  • [PATCH 1/3] UEAGLE : comestic
    ... hint about wrong cmv/dsp ... Display a message to warn user when the modem is ready: it can help people to detect problems on the line without debug trace ... display modem type (pots/isdn) ...
    (Linux-Kernel)