[vtkusers] RE: no response for mouseclicking in samplev31
Nigel Nunn
nNunn at ausport.gov.au
Tue May 15 00:30:39 EDT 2001
Assuming no recent bugs have appeared, a possible
cause is that event messages are being handled by
the overridden virtual method, "WindowProc" in file
vtkMFCRenderView.cpp.
LRESULT vtkMFCRenderView::WindowProc ( UINT message,
WPARAM wParam, LPARAM lParam )
{
switch (message)
{
//case WM_PAINT:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
case WM_CHAR:
case WM_TIMER:
if (this->Interactor->GetInitialized())
{
return vtkHandleMessage2(this->m_hWnd,
message, wParam, lParam, this->Interactor);
}
break;
}
return vtkMFCView::WindowProc(message, wParam, lParam);
}
To use the class wizard, you need to remove this
user-defined WindowProc and add event-handlers in the
usual way. Note that you will still need to pass the
messages on to
vtkHandleMessage2(this->m_hWnd,
message, wParam, lParam, this->Interactor);
Here is a wrapper for that call:
--------------------------------------
LRESULT vtkMFCRenderView::CallInteractor
(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (m_IRen->GetInitialized())
{
return vtkHandleMessage2(m_hWnd,uMsg,wParam,lParam,m_IRen);
}
return 0;
}
A base-class version:
-------------------------------
// Be sure to pass timer messages to Vtk!
void vtkMFCRenderView::OnTimer(UINT nIDEvent)
{
this->CallInteractor(WM_TIMER, (WPARAM)(UINT)(nIDEvent), 0L);
}
void vtkMFCRenderView::OnLButtonDown(UINT nFlags, CPoint point)
{
this->CallInteractor(WM_LBUTTONDOWN,
(WPARAM)(UINT)(nFlags),
MAKELPARAM((point.x), (point.y)));
}
etc...
A version for your derived class:
--------------------------------------
void CMyView::OnLButtonDown(UINT nFlags, CPoint point)
{
m_nUserMode = g_Info.GetUserMode();
//---------------------------------------------
// Handle Camera adjustment
//---------------------------------------------
else if (GetUserMode() == USER_MODE_ZOOM)
{
DoZoom();
}
//---------------------------------------------
// Pass interaction to Vtk
//---------------------------------------------
else
{
vtkMFCRenderView::OnLButtonDown(nFlags, point);
}
}
More information about the vtkusers
mailing list