mirror of
https://github.com/ckaczor/FloatingStatusWindow.git
synced 2026-01-14 01:25:36 -05:00
Allow our messages from non-elevated processes
This commit is contained in:
@@ -77,6 +77,14 @@ internal partial class MainWindow
|
||||
WindowSettings.Apply();
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
WindowManager.AllowMessagesThroughFilter(windowHandle);
|
||||
}
|
||||
|
||||
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg == WindowManager.SetLockMessage)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using ChrisKaczor.Wpf.Windows;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -10,6 +9,11 @@ public static partial class WindowManager
|
||||
{
|
||||
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
private enum ChangeWindowMessageFilterExAction : uint
|
||||
{
|
||||
Allow = 1
|
||||
}
|
||||
|
||||
[LibraryImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial void EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
@@ -26,6 +30,10 @@ public static partial class WindowManager
|
||||
[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
|
||||
private static partial void SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[LibraryImport("user32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial void ChangeWindowMessageFilterEx(IntPtr hWnd, uint msg, ChangeWindowMessageFilterExAction action, IntPtr changeInfo);
|
||||
|
||||
private const string WindowMessageSetLock = "FloatingStatusWindowLibrary_SetLock";
|
||||
private const string WindowMessageClose = "FloatingStatusWindowLibrary_Close";
|
||||
|
||||
@@ -43,6 +51,12 @@ public static partial class WindowManager
|
||||
private static List<WindowInformation> _windowList;
|
||||
private static IntPtr _excludeHandle;
|
||||
|
||||
public static void AllowMessagesThroughFilter(IntPtr hWnd)
|
||||
{
|
||||
ChangeWindowMessageFilterEx(hWnd, SetLockMessage, ChangeWindowMessageFilterExAction.Allow, IntPtr.Zero);
|
||||
ChangeWindowMessageFilterEx(hWnd, CloseMessage, ChangeWindowMessageFilterExAction.Allow, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public static List<WindowInformation> GetWindowList()
|
||||
{
|
||||
lock (WindowLocker)
|
||||
|
||||
Reference in New Issue
Block a user