-->

Delphi VirtualStringTree OnGetHint

2019-02-24 19:25发布

问题:

I want to show hint when cell text is already fully shown.
so, on form's OnCreate

procedure TForm1.FormCreate(Sender: TObject);
begin
  VirtualStringTree1.HintMode := hmHint;
  VirtualStringTree1.ShowHint := True;
end;

and OnGetHint

procedure TForm1.VirtualStringTree1GetHint(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex;
  var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
begin
  HintText := IntToStr(Node.Index);
end;

but nothing happens.

OnGetHint event handler is not fired and even TBaseVirtualTree.CMHintShow breakpoint is not working.

what can I supposed to do?

I`m using delphi xe3, virtualtreeview 5.2.1.


Thanks for the answer.

I followed your guide.

Application properties

  • ShowHint := True // I checked but set to true on OnCreate explicitly

Vst propertiess

  • Hint, e.g. 'Hint for the whole VST' // yes, add meaningless hint
  • HintAnimation, e.g. hatNone
  • HintMode, e.g. hmHintAndDefault // as you see, on OnCreate
  • ShowHint, True// as you see, on OnCreate
  • ParentShowHint, as needed, use False if you don't know // yes

Vst events to implement

  • OnDrawHint() // yes
  • OnGetHint() // yes
  • OnGetHintSize() // yes

but nothing changed.
OnGetHint, OnGetHintSize, OnDrawHint are not fired at all.
(when HintMode set to hmToolTip and text is not fully shown, OnGetHint is fired only)

And yes, I read that documentation VirtualTreeView.pdf.
but all description about Event is exactly same as your quote.
I need more explanation.


Update:

Very weird thing.
I have tested this other PCs.

My PC Windows 10 xe3 vst 5.2.1

  • not work

PC 1 Windows 10 xe3 vst 5.2.1

  • compile and execute // work
  • compile on My PC, copy and execute // work

PC 2 Windows 10

  • compile on My PC, copy and execute // work

What????
the code was not the problem.
I don't know why and even where to start.

anyway, I really thanks about answer and accept it.
if anyone knows about this weird thing, please let me know.
if I find out, I will update.

回答1:

Several properties and event handlers must be in place/implemented for node specific hints to show. The following should get you started:

Application properties

  • ShowHint := True

Vst properties

  • Hint, e.g. 'Hint for the whole VST'
  • HintAnimation, e.g. hatNone
  • HintMode, e.g. hmHintAndDefault
  • ShowHint, True
  • ParentShowHint, as needed, use False if you don't know

Vst events to implement

  • OnDrawHint()
  • OnGetHint()
  • OnGetHintSize()

From the documentation:

Use an event handler for OnDrawHint() to draw the hint or tooltip for the given node. You must implement this event and OnGetHintSize() to get a hint at all.

Look on the net for VirtualTreeView.pdf for documentation