02-15-2007 11:57 PM
02-16-2007 02:18 AM
Hello Subrata,
I'm not sure if I understand your question. I understand that you want some characters pressed on the keyboard, not to be displayed in your string control. To do so, you should catch these keypresses in the Callback function of your string control, when the event parameter is set to EVENT_KEYPRESS. Then, check the key that is pressed, which will be represented by the eventData2 parameter. If you do not want this key to be displayed in the string control, use the SetKeyPressEventKey function to swallow the keypress:
The callback funtion below swallows all digits:
int CVICALLBACK StringCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int key; // The character being pressed.
switch (event) {
case EVENT_KEYPRESS:
// Get the pressed character.
if ((key = GetKeyPressEventCharacter (eventData2)) == 0) break;
// If a digit (0 to 9) is pressed, swallow the keypress.
if (isdigit (key))
SetKeyPressEventKey (eventData2, 0, 0, 0, 0, 0);
break;
}
return 0;
}
I attached the example to this message.
To answer your second question:
Also if I want to display a string (i.e array of characters )and delete a string from string control what functions should I adopt in the application ?.
To set a predefined string, just use the SetCtrlVal function: SetCtrlVal (pnlHandle, PNL_STRING, "This is a string"); This line of code will clear the string control: SetCtrlVal (pnlHandle, PNL_STRING, "");
Good luck,
Wim