怎么把一个窗口置于topmost?--------十分急,分全给了!!!

terrace 2003-08-19 02:42:18
我用FindWindow找到一个窗口(用MessageBox弹出的,可能不属于本应用程序),然后我希望把它设置为topmost状态即置于屏幕的最前面且是激活的,而且关闭该窗口后我原来的程序应仍是active的即有焦点,我试了ShowWindow,但实现不了,有什么办法实现吗?请高手帮忙,很急用,谢谢!!!!
...全文
136 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahjoe 2003-08-20
  • 打赏
  • 举报
回复
Form1.FormStyle := fsStayOnTop;
terrace 2003-08-20
  • 打赏
  • 举报
回复
renzy205朋友:
你好!
根据你的方法我把SetWindowPos(Handle, HWND_TOPMOST, ...)放定时器中如下:
procedure Tfrm_Main.Timer3Timer(Sender: TObject);
var
H:HWnd;
begin
H:=0;
H:=FindWindow(nil,PChar('HF_Main'));
SetWindowPos(H, HWND_TOPMOST,0,0,300,300,SWP_SHOWWINDOW);
SetActiveWindow(H);
end;
能把窗口置于topmost,第一次也能有输入焦点,但以后当我切换到一个程序后该定时器能定期将窗口置于topmost且有光标闪烁却丢了焦点即无法输入,此时焦点在别的程序中,该怎么解决呢?另外如何得到当前屏幕中激活的有焦点可接受输入的窗口
呢?
比较急用,请帮忙看看,万分感谢!!!
budi 2003-08-19
  • 打赏
  • 举报
回复
SetWindowPos(Handle, HWND_TOPMOST, ...)
renzy205 2003-08-19
  • 打赏
  • 举报
回复
SetForegroundWindow(hwindow);
DWGZ 2003-08-19
  • 打赏
  • 举报
回复
protected
procedure CreateParams(var Param:TCreateParams);override;

...
procedure TForm2.CreatePrams(Var Param:TCreateParams);
begin
inherited CreateParams(Param);
with Param do
begin
ExStyle:=ExStyle or WS_EX_TOPMOST or WS_EX_DLGFRAME or WS_EX_TOOLWINDOW;
WndParent := GetDesktopWindow;
end;
end;


jerrymousenet2 2003-08-19
  • 打赏
  • 举报
回复
SetForegroundWindow(hwnd);

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧