问题描述
我有这些光标形状的小表格,需要一直放在一切之上。
FormStyle
已经 fsStayOnTop
我使用以下代码:
I have these little cursor shaped forms that I need to be on Top of everything, all the time...FormStyle
is already fsStayOnTop
I use this code:
SetWindowPos(tempCursor.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE );
这(尽管我不完全知道它的作用):
and this (even though I don't exactly know what it does):
procedure TCursorFrm.CreateParams(var Params: TCreateParams);
const
WS_EX_NOACTIVATE = $8000000;
begin
inherited;
Params.ExStyle := Params.ExStyle + WS_EX_NOACTIVATE;
end;
但我仍然无法将表单放在TMenuItems的顶部。
如何使表单保持在所有内容之上?
but I still cannot get my forms to be on Top of TMenuItems.How can I make my forms stay on top of everything?
推荐答案
这必须是最终的,甚至是最糟糕的
This has to be the ultimate, or worst, piece of hackery I'll publish.
- 将您的FormStyle设置为fsStayOnTop(实际上可能没有必要)
- 在窗体上放置一个TTimer并将其间隔设置为100
-
在OnTimer事件中,放置以下代码:
- Set your FormStyle to be fsStayOnTop (This step may not actually be necessary)
- Drop a TTimer on your form and set it's interval to 100
In the OnTimer event place the following code:
如果可见,则
SetWindowPos(Self.Handle,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE或SWP_NOMOVE或SWP_NOACTIVATE);
if visible then SetWindowPos(Self.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE or SWP_NOACTIVATE);
我正在我的一个项目中使用它,它似乎工作正常。
I'm using this in one of my projects and it seems to work alright.
这篇关于如何使我的表单始终保持在所有内容之上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!