mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[EnvironmentVariables] EnvironmentVariables window set to front when launched. (#30226)
* [EnvironmentVariables] EnvironmentVariables window set to front when launched. * [EnvironmentVariables] BringToForeground function used instead of SetForegroundWindow. * [EnvironmentVariables] BringToForeground is moved to MainWindow constructor. * [EnvironmentVariables] Move 'handle' from class field to local variable in MainWindow constructor.
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
|
|||||||
using EnvironmentVariables.Helpers;
|
using EnvironmentVariables.Helpers;
|
||||||
using EnvironmentVariables.Helpers.Win32;
|
using EnvironmentVariables.Helpers.Win32;
|
||||||
using EnvironmentVariables.ViewModels;
|
using EnvironmentVariables.ViewModels;
|
||||||
|
using ManagedCommon;
|
||||||
using Microsoft.UI.Dispatching;
|
using Microsoft.UI.Dispatching;
|
||||||
using WinUIEx;
|
using WinUIEx;
|
||||||
|
|
||||||
@@ -30,19 +31,20 @@ namespace EnvironmentVariables
|
|||||||
Title = title;
|
Title = title;
|
||||||
AppTitleTextBlock.Text = title;
|
AppTitleTextBlock.Text = title;
|
||||||
|
|
||||||
RegisterWindow();
|
var handle = this.GetWindowHandle();
|
||||||
|
RegisterWindow(handle);
|
||||||
|
|
||||||
|
WindowHelpers.BringToForeground(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
private static readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||||
private static NativeMethods.WinProc newWndProc;
|
private static NativeMethods.WinProc newWndProc;
|
||||||
private static IntPtr oldWndProc = IntPtr.Zero;
|
private static IntPtr oldWndProc = IntPtr.Zero;
|
||||||
|
|
||||||
private void RegisterWindow()
|
private void RegisterWindow(IntPtr handle)
|
||||||
{
|
{
|
||||||
newWndProc = new NativeMethods.WinProc(WndProc);
|
newWndProc = new NativeMethods.WinProc(WndProc);
|
||||||
|
|
||||||
var handle = this.GetWindowHandle();
|
|
||||||
|
|
||||||
oldWndProc = NativeMethods.SetWindowLongPtr(handle, NativeMethods.WindowLongIndexFlags.GWL_WNDPROC, newWndProc);
|
oldWndProc = NativeMethods.SetWindowLongPtr(handle, NativeMethods.WindowLongIndexFlags.GWL_WNDPROC, newWndProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user