Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Windows Drag Copy cursor

I can set a cursor like this:

Me.Cursor = Cursors.Cross

Using IntelliSense, I don't find this "Copy" cursor:

Copy Cursor

Is there any way to get it in a managed way? I wouldn't want to load a bitmap or so. I would like to leave that up to Windows as the user may have changed the cursor size or set a different color schema.

like image 600
tmighty Avatar asked Aug 30 '26 00:08

tmighty


1 Answers

Drag and drop cursors belong ole32.dll. You can load them from that library. To do so, you need to load ole32.dll using LoadLibrary, then using LoadCursor get the handle of those cursors. You can use 1 to 7 as LoadCursor parameter to get cursors from ole32.dll. The cursor which you are looking for is 3 or 6:

enter image description here

[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);

[DllImport("user32.dll")]
public static extern IntPtr LoadCursor(IntPtr hInstance, UInt16 lpCursorName);

private void button1_Click(object sender, EventArgs e)
{
    var l = LoadLibrary("ole32.dll");
    var h = LoadCursor(l, 6);
    this.Cursor = new Cursor(h);
}
like image 118
Reza Aghaei Avatar answered Sep 01 '26 17:09

Reza Aghaei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!