Move TryFixHandCursor to HelpersLib

This commit is contained in:
Charles Milette 2018-04-29 11:30:03 -04:00
parent 82da3e353b
commit d50d3ca7b8
No known key found for this signature in database
GPG key ID: 1A5AE81377AD973A
2 changed files with 19 additions and 14 deletions

View file

@ -1267,5 +1267,22 @@ public static string NumberToLetters(int num)
}
return result;
}
public static bool TryFixHandCursor()
{
try
{
// https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Cursors.cs,423
typeof(Cursors).GetField("hand", BindingFlags.NonPublic | BindingFlags.Static)
?.SetValue(null, new Cursor(NativeMethods.LoadCursor(IntPtr.Zero, NativeConstants.IDC_HAND)));
return true;
}
catch
{
// If it fails, we'll just have to live with the old hand.
return false;
}
}
}
}

View file

@ -30,7 +30,6 @@ You should have received a copy of the GNU General Public License
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
@ -291,7 +290,7 @@ private static void Run()
LanguageHelper.ChangeLanguage(Settings.Language);
TryFixHandCursor();
Helpers.TryFixHandCursor();
DebugHelper.WriteLine("MainForm init started.");
MainForm = new MainForm();
DebugHelper.WriteLine("MainForm init finished.");
@ -504,7 +503,7 @@ private static bool CheckAdminTasks()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
TryFixHandCursor();
Helpers.TryFixHandCursor();
Application.Run(new DNSChangerForm());
return true;
}
@ -585,16 +584,5 @@ private static void CleanTempFiles()
}
}).Start();
}
private static void TryFixHandCursor()
{
try
{
// https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Cursors.cs,423
typeof(Cursors).GetField("hand", BindingFlags.NonPublic | BindingFlags.Static)
?.SetValue(null, new Cursor(NativeMethods.LoadCursor(IntPtr.Zero, NativeConstants.IDC_HAND)));
}
catch { } // If it fails, we'll just have to live with the old hand.
}
}
}