improved menu performance and folder browser fix
This commit is contained in:
@@ -7,6 +7,7 @@ using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Text;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
@@ -101,8 +102,8 @@ namespace MsgBoxEx
|
||||
|
||||
public static IntPtr GetOwnerHandle()
|
||||
{
|
||||
IntPtr foregroundWindow = Native.GetForegroundWindow();
|
||||
Native.GetWindowThreadProcessId(foregroundWindow, out var procID);
|
||||
IntPtr foregroundWindow = GetForegroundWindow();
|
||||
GetWindowThreadProcessId(foregroundWindow, out var procID);
|
||||
|
||||
using (var proc = Process.GetCurrentProcess())
|
||||
if (proc.Id == procID)
|
||||
@@ -111,6 +112,12 @@ namespace MsgBoxEx
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
public static Color ColorFromString(string colorString)
|
||||
{
|
||||
Color wpfColor = Colors.Black;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MsgBoxEx
|
||||
{
|
||||
class Native
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
}
|
||||
}
|
||||
@@ -62,13 +62,12 @@ namespace DynamicGUI
|
||||
switch (StringSetting.Type)
|
||||
{
|
||||
case "folder":
|
||||
using (var d = new WinForms.FolderBrowserDialog())
|
||||
using (FolderBrowser fb = new FolderBrowser())
|
||||
{
|
||||
d.Description = "Choose a folder.";
|
||||
d.SelectedPath = ValueTextBox.Text;
|
||||
fb.SelectedPath = ValueTextBox.Text;
|
||||
|
||||
if (d.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = d.SelectedPath;
|
||||
if (fb.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = fb.SelectedPath;
|
||||
}
|
||||
break;
|
||||
case "color":
|
||||
|
||||
Reference in New Issue
Block a user