mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Use system hand cursor
Universal fix, will fix any affected Form Fixes #3341
This commit is contained in:
parent
d4b050148b
commit
d8c2a7f796
3 changed files with 21 additions and 0 deletions
|
@ -82,6 +82,7 @@ public static class NativeConstants
|
|||
|
||||
public const uint ECM_FIRST = 0x1500;
|
||||
public const uint EM_SETCUEBANNER = ECM_FIRST + 1;
|
||||
public const int IDC_HAND = 32649;
|
||||
public const uint MA_ACTIVATE = 1;
|
||||
public const uint MA_ACTIVATEANDEAT = 2;
|
||||
public const uint MA_NOACTIVATE = 3;
|
||||
|
|
|
@ -193,6 +193,9 @@ public static partial class NativeMethods
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool IsZoomed(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr LoadCursor(IntPtr hInstance, int iconId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
|
||||
|
|
|
@ -30,6 +30,7 @@ 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;
|
||||
|
@ -226,14 +227,23 @@ public static string ScreenshotsFolder
|
|||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
#if !DEBUG // Allow Visual Studio to break on exceptions in Debug builds.
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
#endif
|
||||
|
||||
StartTimer = Stopwatch.StartNew(); // For be able to show startup time
|
||||
|
||||
CLI = new CLIManager(args);
|
||||
CLI.ParseCommands();
|
||||
|
||||
// Fix the hand cursor before we open any form.
|
||||
try
|
||||
{
|
||||
FixHandCursor();
|
||||
}
|
||||
catch (Exception) { } // If it fails, we'll just have to live with the old hand.
|
||||
|
||||
#if STEAM
|
||||
if (CheckUninstall()) return; // Steam will run ShareX with -Uninstall when uninstalling
|
||||
#endif
|
||||
|
@ -580,5 +590,12 @@ private static void CleanTempFiles()
|
|||
}
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private static void FixHandCursor()
|
||||
{
|
||||
// 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)));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue