2010. február 22., hétfő

Display different hints for each node in a TTreeView


Problem/Question/Abstract:

I want to display a hint on a TTreeView which varies from node to node. So I get the node over which the mouse is in the MouseMove event and change the Hint property of the TreeView.

Answer:

Our ElTree has own hints for every item and we did the following:

{ ... }
if (FHintItemEx <> nil) or (not ShowHint) then
begin
  Application.Hint := FOwner.FRealHint;
  Hint := FOwner.FRealHint;
  TSI := GetItemAt(Message.XPos, Message.YPos, IP, HCol);
  if (TSI <> nil) then
  begin
    if (FHintItemEx <> TSI) then
    begin
      if Length(TSI.Hint) > 0 then
      begin
        Application.Hint := TSI.Hint;
        Hint := TSI.Hint;
      end;
      if ShowHint and (not FInDragging) then
      begin
        P := ClientToScreen(SmallPointToPoint(Message.Pos));
{$IFDEF VCL_5_USED}
        Application.ActivateHint(P);
{$ELSE}
        MoveMemory(@AMsg, @Message, sizeof(AMsg));
        TWMMouse(AMsg).XPos := -10000;
        TWMMouse(AMsg).YPos := -10000;
        Application.HintMouseMessage(Self, AMsg);
        TWMMouse(AMsg).Pos := Message.Pos;
        Application.HintMouseMessage(Self, AMsg);
{$ENDIF}
      end;
    end;
  end;
end;
{ ... }

Nincsenek megjegyzések:

Megjegyzés küldése