我一直在努力這樣做,不能做的,這是我到:C#獲取當前光標圖標
[DllImport("user32.dll")]
static extern bool SetSystemCursor(IntPtr hcur, uint id);
[DllImport("user32.dll", EntryPoint = "GetCursorInfo")]
public static extern bool GetCursorInfo(out CURSORINFO pci);
[DllImport("user32.dll", EntryPoint = "CopyIcon")]
public static extern IntPtr CopyIcon(IntPtr hIcon);
[StructLayout(LayoutKind.Sequential)]
public struct CURSORINFO
{
public Int32 cbSize; // Specifies the size, in bytes, of the structure.
public Int32 flags; // Specifies the cursor state. This parameter can be one of the following values:
public IntPtr hCursor; // Handle to the cursor.
public POINT ptScreenPos; // A POINT structure that receives the screen coordinates of the cursor.
}
public void etc()
{
IntPtr hwndic = new IntPtr();
CURSORINFO curin = new CURSORINFO();
curin.cbSize = Marshal.SizeOf(curin);
if (GetCursorInfo(out curin))
{
if (curin.flags == CURSOR_SHOWING)
{
hwndic = CopyIcon(curin.hCursor);
SetSystemCursor(hwndic, OCR_NORMAL);
}
}
}
的問題是,複製的圖標有時是不同於默認鼠標圖標,如果它在等待位置捕捉到它,例如它可能會給我鼠標等待圖標。
我希望獲得正在運行的系統的默認光標圖標(空閒時的圖標),我該怎麼做?
在此先感謝。
看看LoadCursor和IDC_ARROW常量 – Pascalz
@Pascalz不幫我,它沒有檢測到系統的光標是什麼。 –
您可以在複製之前設置Cursor.Current = Cursors.Default嗎? – obl