Page 1 of 1

TToolTipManager on dynamically created frame

PostPosted: October 28th, 2010, 8:45 am
by Ian Hinson
It works OK when I drop a frame onto a form at design-time where the frame contains
1) an edit control and
2) a ToolTipManager.
By properly adding and configuring a ToolTipItem for the edit box, the tool tip appears correctly on the embedded frame at run-time.

However if I create the frame at run-time like this:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
  frame1: TFrame1;
begin
  frame1 := TFrame1.Create(Self);
  frame1.Name := 'Frame1';
  frame1.Parent := Self;
end;

The frame appears on the form ok, but the tool tip does not appear to work.
Am I doing this correctly?
I don't get why the tool tip works ok when the frame is embedded at design-time, but not if it is embedded at run-time.

Thanks.
Ian

Re: TToolTipManager on dynamically created frame

PostPosted: October 28th, 2010, 1:49 pm
by Kambiz
I don't know why this happens, but I have a solution.

After setting Parent property of the frame, call RebuildToolTips method of the ToolTipManager.

Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
  frame1: TFrame1;
begin
  frame1 := TFrame1.Create(Self);
  frame1.Name := 'Frame1';
  frame1.Parent := Self;
  frame1.ToolTipManager1.RebuildToolTips;   // this line resolves the problem
end;