How can I save a window in WPF?

I have a small .NET program that creates a full screen window. I would like to save this window in the rear window itself (that is, other windows should open on top of it, and it should not appear on the front panel when pressed). Is there any practical way to do this in the Windows Presentation Foundation?

+4
source share
1 answer

As far as I know, you will need P / Invoke to do it right. Call the SetWindowPos function , specifying the handle to your window and the HWND_BOTTOM flag.

This will move your window to the bottom of the Z-order and prevent it from shading other windows.

Code example:

 Private Const SWP_NOSIZE As Integer = &H1 Private Const SWP_NOMOVE As Integer = &H2 Private Const SWP_NOACTIVATE As Integer = &H10 <DllImport("user32.dll", CharSet:=CharSet.Auto)> _ Private Shared Function SetWindowPos(hWnd As IntPtr, hWndInsertAfter As IntPtr, X As Integer, Y As Integer, cx As Integer, cy As Integer, uFlags As Integer) As Boolean End Function Public Sub SetAsBottomMost(ByVal wnd As Window) ' Get the handle to the specified window Dim hWnd As IntPtr = New WindowInteropHelper(wnd).Handle ' Set the window position to HWND_BOTTOM SetWindowPos(hWnd, New IntPtr(1), 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE) End Sub 
+2
source

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


All Articles