Win32 programming: vtkWin32RenderWindowInteractor and message WM_LBUTTONDOWN

For a project I am working on, I created a C++/CLI wrapper to a native C++ dll which links the vtk.
Then I pass a window handle to the wrapper to create the 3D Canvas inside a C# application (I pass the handle to the SetParentId on the vtkRenderWindow created inside the C++ dll). So far everything has worked spectacularly well. Except that the c# application uses also a docking manager library (Avalon dock) to let the user detach documents from the main window, to move them to a second PC monitor for example. So I have just encountered a strange problem: whenever a document containing the 3D canvas is detached it stops working correctly.
The mouse move/drag interaction with the actors is not working anymore but the wheel mouse is working. If the document is reinserted into the main window everything is back to normal and works as expected. To be more precise, when the document is detached the first mouse drag works (mouse left button down, mouse move and left button up), from the second time it stops working.
Debugging the vtk I have found that the mouse messages are processed by the function vtkHandleMessage (defined in file VTK-9.1.0\Rendering\UI\vtkWin32RenderWindowInteractor.cxx):

LRESULT CALLBACK vtkHandleMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT res = 0;
vtkRenderWindow* ren;
vtkWin32RenderWindowInteractor* me = 0;

ren = (vtkRenderWindow*)vtkGetWindowLong(hWnd, sizeof(vtkLONG));

if (ren)
me = (vtkWin32RenderWindowInteractor*)ren->GetInteractor();

if (me && me->GetReferenceCount() > 0)
res = vtkHandleMessage2(hWnd, uMsg, wParam, lParam, me);

return res;

and whenever the document is detached form the main window, this function stops receiving the message uMsg 513 (WM_LBUTTONDOWN). Strangely enough it keeps receiving all the other messages, including the WM_LBUTTONUP message and WM_MOUSEMOVE etc… The WM_LBUTTONDOWN is probably necessary for the interaction. This is probably more a Windows programming question, but I hope that the people who implemented the vtkWin32RenderWindowInteractor can give me a clue.

I found that when the document is detached, if I press and keep pressing one of the arrow keys on the keyboard (VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT) and then click with the mouse, WM_LBUTTONDOWN is received again and the drag and drop function works (even if just once). I also see that by pressing the arrows and the mouse button, the graphics in the main window user interface change focus as when the main window receives input from the arrow keys. The vtkHandleMessage (in the previous post I wrote) receives messages for the arrow keys only when the window is linked to the main window. This is probably why I see elements in the main window that change focus as I press those buttons. Maybe when the window is detached there is a wndproc in the main window that stops forwarding messages to the VTK library. I hope to find a way to fix all this.

I solved the problem: it was mostly related to the AvalonDock library so I don’t think it can be of any interest here. I am so happy that everything works now given the complexity of the application.