|
|
@ -7,9 +7,9 @@ using Avalonia.Win32.Interop; |
|
|
|
|
|
|
|
|
namespace Avalonia.Win32 |
|
|
namespace Avalonia.Win32 |
|
|
{ |
|
|
{ |
|
|
class OleContext |
|
|
internal class OleContext |
|
|
{ |
|
|
{ |
|
|
private static OleContext fCurrent; |
|
|
private static OleContext s_current; |
|
|
|
|
|
|
|
|
internal static OleContext Current |
|
|
internal static OleContext Current |
|
|
{ |
|
|
{ |
|
|
@ -18,13 +18,12 @@ namespace Avalonia.Win32 |
|
|
if (!IsValidOleThread()) |
|
|
if (!IsValidOleThread()) |
|
|
return null; |
|
|
return null; |
|
|
|
|
|
|
|
|
if (fCurrent == null) |
|
|
if (s_current == null) |
|
|
fCurrent = new OleContext(); |
|
|
s_current = new OleContext(); |
|
|
return fCurrent; |
|
|
return s_current; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private OleContext() |
|
|
private OleContext() |
|
|
{ |
|
|
{ |
|
|
UnmanagedMethods.HRESULT res = UnmanagedMethods.OleInitialize(IntPtr.Zero); |
|
|
UnmanagedMethods.HRESULT res = UnmanagedMethods.OleInitialize(IntPtr.Zero); |
|
|
@ -43,9 +42,21 @@ namespace Avalonia.Win32 |
|
|
internal bool RegisterDragDrop(IPlatformHandle hwnd, IDropTarget target) |
|
|
internal bool RegisterDragDrop(IPlatformHandle hwnd, IDropTarget target) |
|
|
{ |
|
|
{ |
|
|
if (hwnd?.HandleDescriptor != "HWND" || target == null) |
|
|
if (hwnd?.HandleDescriptor != "HWND" || target == null) |
|
|
|
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return UnmanagedMethods.RegisterDragDrop(hwnd.Handle, target) == UnmanagedMethods.HRESULT.S_OK; |
|
|
return UnmanagedMethods.RegisterDragDrop(hwnd.Handle, target) == UnmanagedMethods.HRESULT.S_OK; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal bool UnregisterDragDrop(IPlatformHandle hwnd) |
|
|
|
|
|
{ |
|
|
|
|
|
if (hwnd?.HandleDescriptor != "HWND") |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return UnmanagedMethods.RevokeDragDrop(hwnd.Handle) == UnmanagedMethods.HRESULT.S_OK; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|