Hi, I'm displaying hints for a column in my TAdvTreeview.
The hint consists of a list of numbers, which I'm separating with CR (#13) to show them on multiple lines. However, as they are numbers, I'd ideally like them to be right aligned. Is there a way to do this?
I've tried putting 'mini-html' in the HintStr (using
) but the standard hint obviously isn't html-aware. I also tried dropping a THTMLHint on the form but that seems to stop the hint being shown at all!!
If you can suggest a way of getting the numbers right-aligned I'd be very grateful.
Regards
Steve
Hi,
Have you tried using AdvOfficeHint?
Hi Pieter,
Do I just need to drop it onto the form? That doesn't work either, it stops the hint showing at all.
I've got AdvTreeview1.ShowHint=TRUE, and I'm using OnGetHintInfo to set AHintInfo. Is there anything else I need to set?
We have tested this here with
AdvTreeView1.Hint := 'Line1'#13#10'<b>Line2</b>';
AdvTreeView1.ShowHint := True;
a THTMLHint on the form which then displays the following result:
Hi Pieter,
Many apologies, the application was using a descendant of TAdvTreeview that I wrote a while ago, which looks to not work with the THTMLHint.
Setting the Hint property as above works for me now. However, do you know if it's possible to display a different hint, depending on the node and column you hover over. I've put some code in 'OnMouseMove' to change the Hint property, but the hint is only shown once, unless my mouse moves out of the treeview and back in. Is there a way of 'resetting' the hint, so it'll show the new hint when the mouse moves over a different cell?
Thanks for the continued support.
Hi,
I put together a sample that demonstrates this. It involves overriding the hint for the hovered node.
unit Unit10;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvCustomControl, AdvTreeViewBase,
AdvTreeViewData, AdvCustomTreeView, AdvTreeView;
type
TAdvTreeViewHint = class(TAdvTreeView)
private
FHintNode: TAdvTreeViewVirtualNode;
protected
procedure HandleMouseMove(Shift: TShiftState; X, Y: Single); override;
function GetHintString: string; override;
function HasHint: Boolean; override;
end;
TForm10 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FHintNode: TAdvTreeViewNode;
public
{ Public declarations }
end;
var
Form10: TForm10;
implementation
{$R *.dfm}
procedure TForm10.FormCreate(Sender: TObject);
var
t: TAdvTreeViewHint;
begin
t := TAdvTreeViewHint.Create(Self);
t.Parent := Self;
t.InitSample;
t.ShowHint := True;
t.Nodes[0].DataString := 'This is my first hint';
t.Nodes[0].Nodes[1].DataString := 'This is my second hint';
end;
{ TAdvTreeViewHint }
function TAdvTreeViewHint.GetHintString: string;
begin
if Assigned(FHintNode) and Assigned(FHintNode.Node) then
Result := FHintNode.Node.DataString
else
Result := inherited GetHintString;
end;
procedure TAdvTreeViewHint.HandleMouseMove(Shift: TShiftState; X, Y: Single);
var
n: TAdvTreeViewVirtualNode;
begin
inherited;
n := XYToNode(X, Y);
if n <> FHintNode then
begin
FHintNode := n;
Application.CancelHint;
end;
end;
function TAdvTreeViewHint.HasHint: Boolean;
begin
if Assigned(FHintNode) and Assigned(FHintNode.Node) then
Result := FHintNode.Node.DataString <> ''
else
Result := inherited HasHint;
end;
end.
Hi Pieter,
Thanks very much for that example, it works perfectly.
My own descendant of TAdvTreeView uses a method 'OnGetHintInfo' to retrieve the Hint, given a Node and Column. I think I can just modify your HandleMouseMove procedure to set another local variable (FHintColumn) using XYToNodeTextColumn, and then in GetHintString call my OnGetHintInfo to set the Hint.
Thanks again for all your help with this issue.
1 Like