File tree Expand file tree Collapse file tree
src/Shared/HandyControl_Shared Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Windows ;
33using System . Windows . Input ;
4- using System . Windows . Interop ;
5- using HandyControl . Tools . Interop ;
4+ using HandyControl . Tools ;
65
76namespace HandyControl . Interactivity
87{
@@ -15,11 +14,7 @@ public void Execute(object parameter)
1514 if ( Application . Current . MainWindow != null && Application . Current . MainWindow . Visibility != Visibility . Visible )
1615 {
1716 Application . Current . MainWindow . Show ( ) ;
18- var hwndSource = ( HwndSource ) PresentationSource . FromDependencyObject ( Application . Current . MainWindow ) ;
19- if ( hwndSource != null )
20- {
21- InteropMethods . SetForegroundWindow ( hwndSource . Handle ) ;
22- }
17+ WindowHelper . SetWindowToForeground ( Application . Current . MainWindow ) ;
2318 }
2419 }
2520
Original file line number Diff line number Diff line change @@ -157,15 +157,13 @@ public static Thickness WindowMaximizedPadding
157157 /// 让窗口激活作为前台最上层窗口
158158 /// </summary>
159159 /// <param name="window"></param>
160- public static void SetWindowToForegroundWithAttachThreadInput ( Window window )
160+ public static void SetWindowToForeground ( Window window )
161161 {
162162 // [WPF 让窗口激活作为前台最上层窗口的方法 - lindexi - 博客园](https://www.cnblogs.com/lindexi/p/12749671.html)
163163 var interopHelper = new WindowInteropHelper ( window ) ;
164- // 以下 Win32 方法可以在 https://github.com/kkwpsv/lsjutil/tree/master/Src/Lsj.Util.Win32 找到
165164 var thisWindowThreadId = InteropMethods . GetWindowThreadProcessId ( interopHelper . Handle , out _ ) ;
166165 var currentForegroundWindow = InteropMethods . GetForegroundWindow ( ) ;
167- var currentForegroundWindowThreadId =
168- InteropMethods . GetWindowThreadProcessId ( currentForegroundWindow , out _ ) ;
166+ var currentForegroundWindowThreadId = InteropMethods . GetWindowThreadProcessId ( currentForegroundWindow , out _ ) ;
169167
170168 // [c# - Bring a window to the front in WPF - Stack Overflow](https://stackoverflow.com/questions/257587/bring-a-window-to-the-front-in-wpf )
171169 // [SetForegroundWindow的正确用法 - 子坞 - 博客园](https://www.cnblogs.com/ziwuge/archive/2012/01/06/2315342.html )
You can’t perform that action at this time.
0 commit comments