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

后端 未结 5 993
梦如初夏
梦如初夏 2021-01-21 03:46

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 cod

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 04:39

    This has to be the ultimate, or worst, piece of hackery I'll publish.

    1. Set your FormStyle to be fsStayOnTop (This step may not actually be necessary)
    2. Drop a TTimer on your form and set it's interval to 100
    3. In the OnTimer event place the following code:

      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.

提交回复
热议问题