LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use a backspace with a text box?

I am using the text box as input and if the operator makes a mistake I want to use the backspace. I am swallowing all of the keyboard events and sending them to a rs-232 device and reading back the echo. When I write the backspace (0x8 ) to the text box it does not move back the cursor and erase the character.
0 Kudos
Message 1 of 3
(3,383 Views)
How do you "write the backspace"?
Does you RS-232 device reecognize the backspace? If it does and all you want to do is correct the text displayed in your textbox, you could just rewrite the text after shortening it by one character.
char szText[1024];
int textLen;
//...
GetCtrlVal (panelHandle, PANEL_TEXTBOX, szText);
ResetTextBox (panelHandle, PANEL_TEXTBOX, "");
if ((textLen = strlen(szText)) >0)
szText[textLen-1] = '\0';
SetCtrlVal (panelHandle, PANEL_TEXTBOX, szText);
0 Kudos
Message 2 of 3
(3,385 Views)
Then How would i be able to get rid of a character in the middle of a string programmatically?
Assuming the place of the cursor is acquired by  GetCtrlAttribute (panelHandle, PANEL_CMD, ATTR_TEXT_SELECTION_START, &idx);
 
I was thinking of cutting a string into two strings. remove the last character of the first string, and then concatenate two strings.
I think there is function that splices a string at desired character length(in this case, it will be idx).
Anyone who can help>???
Thanks,
 
JL
0 Kudos
Message 3 of 3
(3,195 Views)