LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Positioning the cursor at the last line in a text box

I have a text box to receive user commands and display them.  Each line of the text box starts with a prompt character (like a DOS window).    Here is a snippet of the code that gets the command and displays a prompt for the next command:

 

            status = GetTextBoxLine (PANEL, PANEL_TEXTBOX, lineNumber, currentCmd);
            status = InsertTextBoxLine (PANEL, PANEL_TEXTBOX, -1, ">\n");

 

The problem I am having is that I want the cursor to automatically go to the last line of the display, but it always stays at the top line.  If I add the following code per another thread in this forum, the cursor moves to the correct line, but is in front of the prompt character:

 

            SetActiveCtrl (PANEL, PANEL_TEXTBOX);
            FakeKeystroke (VAL_RIGHT_ARROW_VKEY); 

 

The user could move the cursor to the correct location in either of these instances, but that seems like a clunky way of doing things.  Is there a way I can get the cursor to be positioned at the last line of the box programmatically?

 

Thanks.

0 Kudos
Message 1 of 5
(4,850 Views)

Did you consider using SetCtrlAttribute (PANEL, PANEL_TEXTBOX, ATTR_TEXT_SELECTION_START, position)? All you have to do is keeping track of your text box contents, i.e. its length.

 

Wolfgang

0 Kudos
Message 2 of 5
(4,837 Views)

Wolfgang wrote:

Did you consider using SetCtrlAttribute (PANEL, PANEL_TEXTBOX, ATTR_TEXT_SELECTION_START, position)? All you have to do is keeping track of your text box contents, i.e. its length.

 

Wolfgang


 

Alternatively you can use GetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_STRING_TEXT_LENGTH, &x); to obtain the lenght in characters of the text in the textbox without need to trace textbox usage.
Message Edited by Roberto Bozzolo on 05-09-2010 11:42 PM


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?
Message 3 of 5
(4,823 Views)

Alternatively just use SetCtrlVal (panelHandle, PANEL_TEXTBOX, line_to_add). This will automatically keep the cursor on the last line of the box, if the line_to_add string has a '\n' at the end of it.

 

JR

Message 4 of 5
(4,814 Views)

Gentlemen,

 

Thanks for your suggestions.  They helped me to achieve the result I was looking for.

0 Kudos
Message 5 of 5
(4,795 Views)