Add missing EmptyClipboard (#1584)

* Add missing EmptyClipboard

* Fix missing GlobalUnlock
This commit is contained in:
srkizer 2023-12-22 10:56:01 +09:00 committed by GitHub
parent 9ca2d34f95
commit 6eb8153a99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,6 +131,7 @@ internal sealed unsafe class ImGuiClipboardFunctionProvider : IServiceType, IDis
ptr[str.Length] = default;
GlobalUnlock(hMem);
EmptyClipboard();
SetClipboardData(CF.CF_UNICODETEXT, hMem);
}
catch (Exception e)
@ -158,9 +159,9 @@ internal sealed unsafe class ImGuiClipboardFunctionProvider : IServiceType, IDis
return this.clipboardData.Data;
}
var hMem = (HGLOBAL)GetClipboardData(CF.CF_UNICODETEXT);
try
{
var hMem = (HGLOBAL)GetClipboardData(CF.CF_UNICODETEXT);
if (hMem != default)
{
var ptr = (char*)GlobalLock(hMem);
@ -191,6 +192,8 @@ internal sealed unsafe class ImGuiClipboardFunctionProvider : IServiceType, IDis
}
finally
{
if (hMem != default)
GlobalUnlock(hMem);
CloseClipboard();
}