LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

EVENT_KEYPRESS does not swallow keyboard ESC

I want to develop an application with multiple OpenGL panels. In each panel I want to zoom with mouse-click and ESC-button. I have attached a test programme. (Loading instrument driver 'cviogl.fp' from CVI subdir toolslib\custctrl is needed.)
When I select the opengl-panel, I can use the ESC button only once for resetting. I used one of the CVI code examples that show the use of event-swallow for virtual keys. What is wrong with the EVENT_KEYPRESS in my test programme. Or: how to catch the esc (or e.g F12) when the panel is active, to process the event and to remove the keypress from keyboard buffer?
0 Kudos
Message 1 of 3
(3,572 Views)
Hello

This seems to be happening becuase the OGL control has focus and not the panel. When you click on the OGL panel, it gets focus and since it cannot process key press events ( since its an indicator and indicators dont usually recieve key presses),ESC is ignore. The panel has to have focus in order to get the key press. You can use the InstallWinMsgCallback() function ( found in the Programmers toolbox ( under ../CVI/toolslib/toolbox folder) to process all the key presses that CVI recieve for a particular panel. Then check for the escape key to reset the OGL control.

//Install callback
InstallWinMsgCallback(panel,WM_KEYUP,MyCallback,VAL_MODE_IN_QUEUE,NULL,&handle);

//Handle escape in the callback
int CVICALLBACK MyCallback (int panelHandle, int m
essage,
unsigned int* wParam, unsigned int* lParam,
void* callbackData)
{
if(*wParam == VK_ESCAPE){
OpenglFrameResize(1); }

return 0;
}

Dont forget to uninstall the winmsg callback by calling RemoveWinMsgCallback(). You will also need to include the windows.h header as the very first header in your list of includes.

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
Message 2 of 3
(3,572 Views)
Implemented the solution and it works fine.
Thanks, JGS
0 Kudos
Message 3 of 3
(3,572 Views)