?? animatedwaitcursor.cs
字號(hào):
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
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -