LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetKeyPressEventVirtualKey crashing debug

Referring to this post, I am trying to update a control based on numeric data being entered into a numeric control, using the EVENT_KEYPRESS event.  I am attempting to ignore non-numeric entered data (including virtual key codes).  Using the following code, I get consistent lockups of CVI 2013:

 

int temp1, temp2;

case EVENT_KEYPRESS:
	temp = GetKeyPressEventVirtualKey(eventData2);
	if (temp == 0)
		temp = isdigit(eventData1);
	else
		return -1;
	break;

 

As you can see, I even tried swallowing future events. I can set a breakpoint in this event and pass numeric data just fine.  But then when I hit a non-numeric virtual key (Home, F4, etc), after the GetKeyPressEventVirtualKey, my debugger locks up hard and is unrecoverable.

Is this a CVI bug?

0 Kudos
Message 1 of 7
(4,871 Views)

Hi ElectroLund,

I can't find any bug report on this. However, I'm still looking into it for you. 

 

Corey C

Applications Engineer

National Instruments 

Message 2 of 7
(4,846 Views)

@coreyc wrote:

Hi ElectroLund,

I can't find any bug report on this. However, I'm still looking into it for you. 

 

Corey C

Applications Engineer

National Instruments 


Are you filing a new car?

0 Kudos
Message 3 of 7
(4,833 Views)

Hey ElectroLund,

 

Could you post the simpliest version of your code. I've used your snippet on CVI 2013 and got a fatal runtime. 

 

Corey C

Applications Engineer

National Instruments 

0 Kudos
Message 4 of 7
(4,800 Views)

Just adding that there is an article in the help manual about event swallowing:

LabWindows/CVI 2012 Help: Swallowing Events

 

This article is basically the same in the LabWindows/CVI 2013 SP1 Help Manual (which I have installed on my computer). I would try making a simple project where the only code is main function and one callback to swallow keypress events and the only thing that event does is return 1. For troubleshooting, it's best to start simple and build up to find the problem.

Taylor B.
National Instruments
0 Kudos
Message 5 of 7
(4,712 Views)

I just tried out some simple code, and it appears to be swallowing events without locking up. Is the lock up perhaps when you're swalling an event like exitting out of the panel so that you can no longer click out of the panel?

My Code:

 

int CVICALLBACK ProcessEvents(int panel, int event, void *callbackData, int eventData1, int eventData2)

// ProcessEvents is the callback for my panel in the UIR file

{

     int keyEvent = 0;

    switch (event) {

        case EVENT_LEFT_CLICK :

            SetCtrlVal (panelHandle, PANEL_EVENT, "left click");

            break;

        case EVENT_KEYPRESS :

            //Keycheck (eventData1);

            keyEvent = 1;

            break;

        }

 

    if(keyEvent == 0)

                             return(0);

                else

                                return 1;

}

 

Taylor B.
National Instruments
0 Kudos
Message 6 of 7
(4,709 Views)

Good questions/thoughts, TBirkulosis. When I get some more time to return to this project, I will test. 

 

But in general, you are very correct.  I owe it to myself to start more simple, rather than blindly swallow events and "hope for the best."

 

Cheers

0 Kudos
Message 7 of 7
(4,694 Views)