LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get a Text Box Vertical Scroll Bar to stay at the bottom of the box?

In CVI 8.1, I have a Text Box with vertical scroll bars.  I feed it lines of text as in a command history logger.  When the text box is full, the vertical scroll bar starts to move "up" the text box.  Is there a way to keep the srcoll bar at the bottom, so that the last line is always visible?
 
thanks
bilg
0 Kudos
Message 1 of 7
(8,150 Views)
I suggest you to use SetCtrlVal to add text to the textbox: text is appended to the end of the control and the last line remains always visible. You can experiment with <cvidir>\samples\userint\textbox.prj example and look what happens while adding and / or deleting text in a textbox in various ways.


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 2 of 7
(8,136 Views)

I use two different ways to do this.

1) use a listbox instead of a text box and use

InsertListitem(PanelHandle, controlID, StringVal, 0);  // the 0 is an arbitrary number not pertitnent

GetNumListItems(PanelHandle, controlID, &count);

SetCtrlIndex(PanelHandle, controlID, count-1 );

Alternately, you could do:

InsertListitem(PanelHandle, controlID, StringVal, itemsAddedCount); 

SetCtrlIndex(PanelHandle, controlID, itemsAddedCount );

itemsAddedCount++;

 

2) if you want to keep a Textbox, if you use

InsertTextBoxLine(PanelHandle, ControlID, -1, StringVal);

it adds the string in stack format (last string is on top) and then the scroll bar stays at the top to show the most recent additions.  You have to get used to looking at it from bottom up instead of top down to view the items as they occurred.

 

 

0 Kudos
Message 3 of 7
(8,134 Views)

Roberto, I had been using SetCtrlAttribute, so going to SetCtrlVal was quick and easy and it worked exactly as you said.

Thanks to all

0 Kudos
Message 4 of 7
(8,122 Views)
On Apr 26, 11:40 am, bglat <x...@no.email> wrote:
> Roberto, I had been using SetCtrlAttribute, so going to SetCtrlVal was quick and easy and it worked exactly as you said.
> Thanks to all

I use the following code snippet to achieve what I believe that you
were asking as I was running a test monitor and I was filling up the
textbox rather fast. With the following function, when the textbox
fills up, the last line remains visible as each successive line gets
inserted:

int MakeLastTextBoxLineVisible()
{
int count, first, visible;

// adjust first visible line as needed to make last inserted line
visible
GetNumTextBoxLines (gTestTab, TEST_TEXTBOX, &count);
GetCtrlAttribute (gTestTab, TEST_TEXTBOX, ATTR_FIRST_VISIBLE_LINE,
&first);
GetCtrlAttribute (gTestTab, TEST_TEXTBOX, ATTR_VISIBLE_LINES,
&visible);
if (first + visible < count)
{
SetCtrlAttribute (gTestTab, TEST_TEXTBOX, ATTR_FIRST_VISIBLE_LINE,
count - visible / 2);
}
gCurTextBoxLine = count - 2; // get the first visible line number
ProcessDrawEvents();
return 0;
}

I insert this function after the last 'InsertTextBoxLine' of my test
logging function. The 'gCurTextBoxLine' variable is used to replace
the last inserted textbox line as follows:
ReplaceTextBoxLine (gTestTab, TEST_TEXTBOX, gCurTextBoxLine, "Running
the version number test: [FAIL]");

Hope this makes sense and helps!

Message 5 of 7
(8,115 Views)

I am having exact the same problem.

 

I have been clicking around for ages, but where are these "properites" hidden away???????????

 

Is there a reference sample vi that someone can put up here?

0 Kudos
Message 6 of 7
(7,423 Views)

I can suggest you two ways to have a list of attributes applicable to a specific control:

 

1. Right-click on the control and select "Control help": in the control overview page of the online help you can choose you can select "control attributes" hyperlink to jump to a list of all attributes related to the specific control you are using (the same applies for functions and events)

 

2. Open the function panel for SetCtrlAttribute ( )  function, click "Control attribute" field next choose the control you are interested on in "Control type" field on top of the windows that appears: the list of attributes will show active only the attributes applicable to that control type, while the others are grayed out



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 7 of 7
(7,421 Views)