зеркало из https://github.com/dotnet/winforms.git
[release/9.0] Fix GetFormats and GetDataPresent (#12193)
Fix formats for file drop
This commit is contained in:
Родитель
ed3e6c60a0
Коммит
176a01307e
|
@ -515,17 +515,11 @@ public unsafe partial class DataObject
|
|||
|
||||
enumFORMATETC.Value->Reset();
|
||||
|
||||
Com.FORMATETC[] formatEtc = [default];
|
||||
HRESULT hr;
|
||||
Com.FORMATETC formatEtc = default;
|
||||
|
||||
fixed (Com.FORMATETC* pFormatEtc = formatEtc)
|
||||
while (enumFORMATETC.Value->Next(1, &formatEtc) == HRESULT.S_OK)
|
||||
{
|
||||
hr = enumFORMATETC.Value->Next(1, pFormatEtc);
|
||||
}
|
||||
|
||||
if (hr == HRESULT.S_OK)
|
||||
{
|
||||
string name = DataFormats.GetFormat(formatEtc[0].cfFormat).Name;
|
||||
string name = DataFormats.GetFormat(formatEtc.cfFormat).Name;
|
||||
if (autoConvert)
|
||||
{
|
||||
string[] mappedFormats = GetMappedFormats(name)!;
|
||||
|
@ -538,6 +532,8 @@ public unsafe partial class DataObject
|
|||
{
|
||||
distinctFormats.Add(name);
|
||||
}
|
||||
|
||||
formatEtc = default;
|
||||
}
|
||||
|
||||
return [.. distinctFormats];
|
||||
|
@ -564,7 +560,9 @@ public unsafe partial class DataObject
|
|||
|
||||
using var nativeDataObject = _nativeDataObject.GetInterface();
|
||||
HRESULT hr = nativeDataObject.Value->QueryGetData(formatEtc);
|
||||
return hr.Succeeded;
|
||||
|
||||
// APIs will return S_FALSE, which is "success"
|
||||
return hr == HRESULT.S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче