key press event can't work in MFC

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

key press event can't work in MFC

I've already implement a VTK render window in my MFC window, everything works well except I have to click the render window again to make the key press events get called. It seems my MFC window is intercepting the key pressed events. Is there any method to help me focus the cursor at the render window?
Clicking the window before entering a key is really annoying.

Here is my code:

this->mainView  = new vtkMFCWindow(this->GetDlgItem(IDC_MAIN_VIEW));
vtkSmartPointer<vtkInteractorStyleImage> imageStyle = vtkSmartPointer<vtkInteractorStyleImage>::New();


this->mainView->GetInteractor()->AddObserver(vtkCommand::KeyPressEvent, slicer);