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;
vtkWin32RenderWindowInteractor* me = 0;
ren = (vtkRenderWindow*)vtkGetWindowLong(hWnd, sizeof(vtkLONG));
me = (vtkWin32RenderWindowInteractor*)ren->GetInteractor();
if (me && me->GetReferenceCount() > 0)
res = vtkHandleMessage2(hWnd, uMsg, wParam, lParam, me);
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.