怎样实现最顶层的窗口?????急急急!!!!!!!!!!!!!

kuyu310 2003-05-23 12:55:14
要求窗口要在任何程序窗口之上,而且要以模态显示
...全文
60 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueshrimp 2003-05-23
  • 打赏
  • 举报
回复
窗口要始终浮在所有窗口的最上面

这个问题我已回答过我次,好像应该这样做:

Public

procedure Createparams(Var Params:TCreateParams);override;

...

procedure TFormDrop.Createparams(var Params:TCreateParams);

begin

Inherited CreateParams(Params);

With Params do

begin

EXStyle:=ExStyle or WS_EX_TOPMOST OR WS_EX_ACCEPTFILES or WS_DLGFRAME

wndParnet:=GetDesktopWindow; //关键一行,用SetParent都不行!!

end;

end;

 

procedure SetFormOnTop(Form: TForm; const bFlag: Boolean);

begin

if bFlag then

SetWindowPos(Form.handle, HWND_TOPMOST, 0, 0, 0, 0, swp_nomove or swp_nosize)

else

SetWindowPos(Form.handle, HWND_NOTOPMOST, 0, 0, 0, 0, swp_nomove or swp_nosize);

end;


yhj78 2003-05-23
  • 打赏
  • 举报
回复
把窗体的FormStyle 设置成fsStayOnTop就可以了
这样最简单!
zxe3tec 2003-05-23
  • 打赏
  • 举报
回复
同意 AWolfBoy(龍行江湖)的说法,在我设计的程序中使用form1.formstyle:=fsStayOnTop就可以实现你的想法。
智商无下限 2003-05-23
  • 打赏
  • 举报
回复
来晚了 !!!
firetoucher 2003-05-23
  • 打赏
  • 举报
回复
1 form1.formstyle:=fsStayOnTop
2 用api函数SetWindowPos(form1.handle, HWND_TOPMOST,...),注意包含windows单元
3 调用ShowModal代替Show

The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

BOOL SetWindowPos(
HWND hWnd, // handle to window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning options
);
Parameters
hWnd
[in] Handle to the window.
hWndInsertAfter
[in] Handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values. Value Meaning
HWND_BOTTOM Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP Places the window at the top of the Z order.
HWND_TOPMOST Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
AWolfBoy 2003-05-23
  • 打赏
  • 举报
回复
把窗体的FormStyle 设置成fsStayOnTop就可以了

1,183

社区成员

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

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