河南精准扶贫最新消息:如何用delphi使某一窗口显示在最前面

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/08 11:29:19
我想用delphi使一个程序的窗口能在最前面显示,问题是这个窗体时已存在的程序而不是我创建的。

下面的代码可以完成你要的功能
如果有不明白可以联系qq 1988723

procedure setWindowTopMost;
var p:TPoint;
childWnd,parentWnd:HWND;
begin
GetCursorPos(p);
childWnd:=WindowFromPoint(p);
parentWnd:=GetParent(childWnd);
if parentWnd<>GetDesktopWindow then
begin
SetWindowPos(childWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
end;
end;

找到这个窗体的句柄就可以设了

方案一 project -〉options ->将其设置为主窗体
方案二 修改窗体的属性formstyle 设其为fsstayontop
可以在其他单元中,用代码把它关闭