📄 animatedwaitcursor.cs
字号:
using System;
using System.Runtime.InteropServices;
namespace AnimatedCursorTest
{
public sealed class AnimatedWaitCursor : IDisposable
{
private IntPtr hLib;
private IntPtr hOldCursor;
private IntPtr hNewCursor;
public AnimatedWaitCursor(string dll, UInt32 ResourceId, int cFrames, int FrameTimeInterval)
{
// Load the dll that contains the animated cursor bitmaps
hLib = LoadLibrary(dll);
if (hLib == IntPtr.Zero)
throw new ArgumentException("Could not load specified dll", "dll");
// Load the animated cursor
hNewCursor = LoadAnimatedCursor(hLib, ResourceId, cFrames, FrameTimeInterval);
if (hNewCursor == IntPtr.Zero)
throw new ArgumentException("Could not load specified cursor");
// Make the animated cursor the active cursor
// and keep track of the previously active cursor.
hOldCursor = SetCursor(hNewCursor);
}
public void Dispose()
{
// Replace the cursor with the
// previous cursor.
if (hNewCursor != IntPtr.Zero)
{
SetCursor(hOldCursor);
}
// Unload the DLL that contains th
// animated cursor bitmaps.
if (hLib != IntPtr.Zero)
{
FreeLibrary(hLib);
}
}
#region Platform Invokes
[DllImport("coredll.dll")]
private static extern IntPtr LoadLibrary(string lpLibFileName);
[DllImport("coredll.dll")]
private static extern int FreeLibrary(IntPtr hLibModule);
[DllImport("coredll.dll")]
private static extern IntPtr LoadAnimatedCursor(IntPtr hInstance, UInt32 ResourceId, int cFrames, int FrameTimeInterval);
[DllImport("coredll.dll")]
private static extern IntPtr SetCursor(IntPtr hCursor);
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -