Disable Form Rising Up

I need a form that, when I set the bottom of the z-order, stays there. I tried:

SetWindowPos(Handle,HWND_BOTTOM,Left,Top,Width,Height,SWP_NOZORDER); 

and when I overlap it with some other applications, it stays down when I need it. However, when I click on it, it rises. Then I tried:

 SetWindowPos(Handle, HWND_BOTTOM, Left, Top, Width, Height, SWP_NOACTIVATE or SWP_NOZORDER); 

and various other keys from this website ... http://msdn.microsoft.com/en-us/library/ms633545.aspx

But he still rises.

+4
source share
3 answers

SetWindowPos sets the position of the window only when it is called, it does not set the state. Handling WM_WINDOWPOSCHANGING is the right way:

While this message is being processed, changing any of the values ​​in WINDOWPOS affects the window of a new size, position or place in the Z order. An application can prevent window changes by setting or clearing the corresponding bits in the WINDOWPOS flag member.


 type TForm1 = class(TForm) .. private procedure WindowPosChanging(var Msg: TWMWindowPosMsg); message WM_WINDOWPOSCHANGING; end; .. procedure TForm1.WindowPosChanging(var Msg: TWMWindowPosMsg); begin if Msg.WindowPos.flags and SWP_NOZORDER = 0 then Msg.WindowPos.hwndInsertAfter := HWND_BOTTOM; inherited; end; 
+8
source

I never tried it, but you can get somewhere, catching the WM_WINDOWPOSCHANGING message, and hide with the Z-order. It can be difficult, although I personally find it annoyingly unconventional.

A menu option equivalent to cacsade, but with z-order sorting might be the best option, I mean, if they clicked on it, they expected to see it.

+1
source

Due to instinct, I would not believe that the application will always work as you expect. In other applications, there can be a much stricter method of forcing your self to be in front of yours, or vice versa in your case, sending it back. For example, a timer that resends the window back. Then, if you have two such applications superimposed on layers, you will see how they fight with each other, mostly flickering back and forth. In the end, I will not count on a permanent 100% solution for this, because you never know what other applications can do to override yours.

0
source

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


All Articles