LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

string control related display

 
 
In my project I am using a String Control  . Now, I am pressing a key and displaying that character on string control . Now I want some characters will not be displayed but read through keyboard . 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 ?.
 
With Regards
 subrata
0 Kudos
Message 1 of 2
(3,075 Views)

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

Message 2 of 2
(3,072 Views)