THintWindow を作成し、その上に TButton または TFrame を配置しようとしています。ここに私のコードがあります:
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;
ヒント ウィンドウは表示されますが、TButton が表示されません。Hintウィンドウ内に子ウィンドウがないようです(「最初の子」についてSpy ++でテストしました)。また、THintWindow を新しい CreateParams でサブクラス化しようとしました。
procedure TMyHintWindow.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_CLIPCHILDREN;
Params.ExStyle := Params.ExStyle or WS_EX_CONTROLPARENT;
end;
ヒント ウィンドウで TFrame を子として作成すると、Spy++ はヒント ウィンドウに子があることを示しますが、(強制的に表示させた後でも)表示できません。
これに関するフィードバックはありますか?