I am trying to use this function from a COM API which enables the window to receive drops (as in drag & dop) from another application.
It is pretty straightforward in Windows Forms and works:
public void EnableDropSupport(System.Windows.Forms.Form form)
{
IntPtr hwnd = form.Handle;
_comAPI.RegisterDropWindow((int)hwnd);
}
But I have a WPF window where it does not work and I don't understand why. I have tried the following:
public void EnableDropSupport(System.Windows.Window window)
{
window.AllowDrop = true;
WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window);
IntPtr hwnd = windowInteropHelper.Handle;
_comAPI.RegisterDropWindow((int)hwnd);
}
The last two lines are basically identical but it will just not work in WPF. While
window.AllowDrop = true;
will make it appear as if it will accept the drop, the drop event of that COM API is not raised.
Am I missing something or can someone help?