High DPI multi monitor fix

This commit is contained in:
Frank Skare
2021-05-13 11:53:36 +02:00
parent 69857e0548
commit 8df330b7aa
9 changed files with 142 additions and 84 deletions

View File

@@ -167,6 +167,11 @@ namespace mpvnet
{
public static string ApplicationKey { get; } = @"HKCU\Software\" + Application.ProductName;
public static void SetInt(string name, object value)
{
SetValue(ApplicationKey, name, value);
}
public static void SetValue(string path, string name, object value)
{
using (RegistryKey regKey = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))

View File

@@ -21,7 +21,7 @@ namespace mpvnet
Application.SetCompatibleTextRenderingDefault(false);
if (App.IsStartedFromTerminal)
WinAPI.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
if (core.ConfigFolder == "")
return;
@@ -73,15 +73,15 @@ namespace mpvnet
{
if (proc.MainWindowHandle != IntPtr.Zero)
{
WinAPI.AllowSetForegroundWindow(proc.Id);
var data = new WinAPI.COPYDATASTRUCT();
Native.AllowSetForegroundWindow(proc.Id);
var data = new Native.COPYDATASTRUCT();
data.lpData = string.Join("\n", args2.ToArray());
data.cbData = data.lpData.Length * 2 + 1;
WinAPI.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
Native.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
mutex.Dispose();
if (App.IsStartedFromTerminal)
WinAPI.FreeConsole();
Native.FreeConsole();
return;
}
@@ -97,7 +97,7 @@ namespace mpvnet
Application.Run(new MainForm());
if (App.IsStartedFromTerminal)
WinAPI.FreeConsole();
Native.FreeConsole();
mutex.Dispose();
}