Page 1 of 1

So erstellen Sie einen WPF -Cursor aus einem INTPTR -Handle

Posted: 14 Apr 2025, 11:49
by Anonymous
Angenommen, ich habe den Handle eines Cursors, und ich möchte eine Instanz von WPF Cursor verwenden. Irgendeine Idee, wie man dies umgeht und einen WPF -Cursor aus dem INTPTR -Handle erstellt?

Code: Select all

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

[DllImport("user32.dll")]
private 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);
}