为了使窗口置顶,重载了如下过程:type
  TXXXForm = class(TForm)
  //...
    procedure CreateParams(var Params: TCreateParams); override;
  //...
  end;implementationprocedure TXXXForm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.WndParent := GetDesktopWindow; // 重新指定窗口的父窗口为桌面顶层窗口
end;如此一来,成功实现了窗口置顶.但该方法是在窗口创建时就改变其父窗口,而我还想得到更灵活的实现方法,随时随地都能控制窗口置顶.
终于找到SetParent这个API,想用它来动态地改变窗口的父窗口指向,以模仿上面的原理.参考了MSDN后我是这样写的:Windows.SetParent(Self.Handle, GetDesktopWindow);
SetWindowLong(Self.Handle, GWL_STYLE, GetWindowLong(Self.Handle, GWL_STYLE) and (not WS_CHILD) or WS_POPUP);但实际确不起任何效果!
是否我对 SetParent 使用得不对?或还漏掉了什么?望解答,谢谢!没有使用 SetWindowPos 或 FormStyle := fsStayOnTop,是因为它们达不到我所要的效果.
所以,请回贴的朋友不要提及 SetWindowPos 或 FormStyle := fsStayOnTop 等字眼了.