How can I get my form to be on top of everything all the time?

I have these little cursor shaped forms that I need to be on top of all the time ...
FormStylealready fsStayOnTop
I am using this code:

 SetWindowPos(tempCursor.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE );

and this (although I don’t know exactly what he is doing):

procedure TCursorFrm.CreateParams(var Params: TCreateParams);
const
   WS_EX_NOACTIVATE = $8000000;
begin
   inherited;
   Params.ExStyle := Params.ExStyle + WS_EX_NOACTIVATE;
end;

but I still can’t get my forms at the top of TMenuItems. How to make my forms stay on top of everything?

+3
source share
5 answers

This must be the final or worst part of the hacking that I will post.

  • Set your FormStyle as fsStayOnTop (this step may not be necessary)
  • Drop the TTimer in your form and set the interval to 100
  • In the OnTimer event, enter the following code:

    , SetWindowPos (Self.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE SWP_NOMOVE SWP_NOACTIVATE);

, , .

+4

, , . , , . - , , , , . , , , , .

+4

, : 10 :

BringWindowToTop(Handle)

, ! , " ", , .

+2

, DirectX. , . . . .

+2

SetWindowPos - :

if visible then form1.SetFocus;
0

Source: https://habr.com/ru/post/1754531/


All Articles