private
procedure SetStayOnTop(Value: Boolean);
property StayOnTop: Boolean write SetStayOnTop;
implementation
{$R *.dfm}
//窗口最上方显示
procedure OSPStayOnTop(Handle: HWND; OnTop: Boolean);
const
csOnTop: array[Boolean] of HWND = (HWND_NOTOPMOST, HWND_TOPMOST);
begin
SetWindowPos(Handle, csOnTop[OnTop], 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end;
//窗体是否总在最前面
procedure Tform1.SetStayOnTop(Value: Boolean);
begin
OSPStayOnTop(Handle, Value);
end;
//调用
Self.StayOnTop := True/False
看明白了吗?