[vtkusers] vtkWin32RenderWindowInteractor problems

Roland Schwarz roland.schwarz at chello.at
Thu Apr 4 00:17:24 EST 2002


Hi Carl,

>From your listing I can see the following:

1)
It seems as if you are trying to embedd a window that is beeing managed by
you. Are you? The vtkWin32RenderWindow may be operated in two different
scenarios. If you already have a window, and just want your messages beeing
handled by vtkWin32RenderWindow you need to call SetWindowId. If you don't,
or if the result of reinterpret_cast<void*>(window) evaluates to NULL, the
vtkWin32renderWindow will create a window on its own (and manage it).

2)
>   vtkw->SetWindowId(reinterpret_cast<void*>(window);
You need to pass a HWND Windows Window handle here. What type is your
Window? reinterpret_cast does a bit level reinterpret. This is most likely
not what you want here. If your class has a conversion operator that will
convert a calss pointer to its embedded HWND you may use a cast. but most
likely it does not have one.

2)
After having set the Window Id you should call vtkw->Initialize(). Also
first set the parent Window Id using vtkw->SetParentId(...)

3)
Do not call interact->SetInstallMessageProc(false);

4) To get your messages handled properly you should not
> case WM_LBUTTONUP:
>   interact->OnLButtonUp(window, 0, LOWORD(lparam), HIWORD(lparam));
>   break;
and the like.
vtkHandleMessage2(....);
instead.


To summarize: You either can delegate from your window to a second window,
then
do not call SetWindowId and use Use interact->OnLButtonUp,
or
you can subclass your window, the use SetWindowID with a proper HWND and
call
vtkHandleMessage2 .


To give you more help I would need to know more about your window.
If you are compiling for MFC I have an example for you if you like.


Roland

----- Original Message -----
From: "Carl Hetherington" <lists at carlh.net>
To: "VTK Mailing list" <vtkusers at public.kitware.com>
Sent: Wednesday, April 03, 2002 12:15 PM
Subject: [vtkusers] vtkWin32RenderWindowInteractor problems


> Hi,
>
> I am writing a Win32 task and there is one window that I want VTK to
> plot.
>
> The relevant bits of the setup code are:
>
>   render = vtkRenderer::New();
>   vtkw = vtkRenderWindow::New();
>   /* window is the HWND of my task's window */
>   vtkw->SetWindowId(reinterpret_cast<void*>(window);
>   vtkw->AddRenderer(render);
>
>   render->AddActor(act);
>   render->SetActiveCamera(camera);
>   render->ResetCamera();
>
>   interact = vtkWin32RenderWindowInteractor::New();
>   interact->SetRenderWindow(vtkw);
>   interact->SetInstallMessageProc(false);
>   interact->Initialize();
>
> Now I also respond to some window events as follows:
>
> case WM_LBUTTONDOWN:
>   interact->OnLButtonDown(window, 0, LOWORD(lparam), HIWORD(lparam));
>   break;
>
> case WM_LBUTTONUP:
>   interact->OnLButtonUp(window, 0, LOWORD(lparam), HIWORD(lparam));
>   break;
>
> case WM_MOUSEMOVE:
>   interact->OnMouseMove(window, 0, LOWORD(lparam), HIWORD(lparam));
>   break;
>
> The scene plots fine but mouse rotation doesn't work.  Strangely, though,
> the window responds correctly to being re-sized, even though I don't
> explicitly pass the WM_SIZE event back to VTK.
>
> Am I going about this the wrong way?  Can anyone help?
>
> Thanks
> Carl
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>






More information about the vtkusers mailing list