LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting Carriage Return in a TextBox

I am trying to take text that from a TextBox control and copy it into a string that can be copied to the clipboard using ClipboardPutText().  I have word wrap turned on for my textbox for readability.  The problem I am having is that I find it impossible to detect whether a new line has been formed due to word wrapping, or the user inserting a carriage return.  Using GetTextBoxLine() to get a line from the textbox does not return any sort of new line information (such as a carriage return at the end if necessary).  Thus when copying to the clipboard I must either insert a carriage return after each line in the text box or ignore carriage returns all together (either way, potentially messing up the intended formatting of the information).  Does anybody have any hints or advice on detecting whether the next line was formed due to word wrapping or due to a carriage return?
 
Note I am not using an evenly spaced font (like courier) so there is no telling how many characters may be entered on a given line.
 
Thanks
Jonathan Rice
0 Kudos
Message 1 of 4
(5,435 Views)
Instead of readinig line by line, you could get all the text of the textbox in a single variable with SetCtrlVal: in the string you should find some newline character (0x0A) embedded where the user has added an actual carriage return (on a word wrap no newline character nor carriage return is added to the string).


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(5,428 Views)

Thanks Roberto, that worked like a charm (and as expected).  For some reason I could have sworn I had already tried that and it did not behave as it should have.  Oh well, I appreciate the help.  By the way, I assume you mean GetCtrlVal instead of SetCtrlVal, since I am trying to get the data out of the textbox.

Thanks

Jonathan Rice

0 Kudos
Message 3 of 4
(5,409 Views)
I'm happy you solved your problem. Of course the SetCtrlVal was a typo: sometime my fingers don't really follow brain instructions! Smiley Wink


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(5,394 Views)