mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +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.Win32;
|
||||
using EnvironmentVariables.ViewModels;
|
||||
using ManagedCommon;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using WinUIEx;
|
||||
|
||||
@@ -30,19 +31,20 @@ namespace EnvironmentVariables
|
||||
Title = title;
|
||||
AppTitleTextBlock.Text = title;
|
||||
|
||||
RegisterWindow();
|
||||
var handle = this.GetWindowHandle();
|
||||
RegisterWindow(handle);
|
||||
|
||||
WindowHelpers.BringToForeground(handle);
|
||||
}
|
||||
|
||||
private static readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
private static NativeMethods.WinProc newWndProc;
|
||||
private static IntPtr oldWndProc = IntPtr.Zero;
|
||||
|
||||
private void RegisterWindow()
|
||||
private void RegisterWindow(IntPtr handle)
|
||||
{
|
||||
newWndProc = new NativeMethods.WinProc(WndProc);
|
||||
|
||||
var handle = this.GetWindowHandle();
|
||||
|
||||
oldWndProc = NativeMethods.SetWindowLongPtr(handle, NativeMethods.WindowLongIndexFlags.GWL_WNDPROC, newWndProc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user