I am trying to create a THintWindow and place a TButton or a TFrame on it. here is my code:
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
HintWindow: THintWindow;
public
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HintWindow := THintWindow.Create(Self);
HintWindow.Color := clInfoBk;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
P: TPoint;
R: TRect;
Control: TControl;
begin
Control := Button1;
P := Control.ClientToScreen(Point(0, Control.Height));
R := Rect(P.X, P.Y, P.x + 100, P.Y + 100);
with TButton.Create(HintWindow) do
begin
Parent := HintWindow;
Caption := 'My Button';
end;
HintWindow.ActivateHint(R, 'My Hint');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
HintWindow.ReleaseHandle;
end;
The Hint window is shown but I don't see the TButton. it seems that there are no child windows inside the Hint window (I tested with Spy++ for "first child"). I also tried to subclass THintWindow with new CreateParams ie:
procedure TMyHintWindow.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_CLIPCHILDREN;
Params.ExStyle := Params.ExStyle or WS_EX_CONTROLPARENT;
end;
When I create a TFrame as child on the Hint window, Spy++ shows that there is a child on the hint window but I cant see it (even after I force it to be visible).
Any feed-backs on this?