LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

length of text displayed in string control

I'd say that Bob is a subject-matter expert in this case.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 11 of 16
(1,129 Views)

@Hooovahh wrote:

Okay well how about this.  You can use the function I mentioned to get the total size of the string, or rather how large the string control needs to be to show all of it.  You can then get the size of the control using other property nodes.  Then you can know the ratio between the total string size, and the amount that is currently shown...of course this does have one major issue that I can't think of an elegant way to fix, the wrapping text.

 

You will likely have a control with a bunch of text that wraps down to other lines.  The Pict Rect function I gave before doesn't know about the string control size it is going into and you'd either have to get creative, or insert returns where they are needed, based on the string size and control size.  All very ugly.  If it were me, I'd count the number of lines, and use that as the needed scrollbar size.  It wouldn't be as elegant but would take a little less time to implement.


I know I am reviving an old thread, but here is a possible quick solution that may or may not work, haven't tested completely yet. (I have the same problem as the OP.) Use the function Hooovahh recommended, Pict Rect function, however, input the string you want with ALL linebreaks removed. Count all the linebreaks that you remove; multiply that number by the font size. The area of the rect plus the aforementioned sum should be close to the minimum size needed to contain all of the font. If the area of your string indicator area is bigger than this, then you don't need a scrollbar.

 

mcduff

Message 12 of 16
(501 Views)

What exactly is the problem using the Text->DocumentBounds property for the required size to display the entire string and comparing that to Text->Bounds for the display size?  I have done similar things and do not recall needing anything more than this.  DocBounds/FontSize = # lines.  The biggest downside to rolling your own that I remember is that the scrolling is quantized by line instead of smooth scrolling with the built-in scrollbars.

Message 13 of 16
(488 Views)

@Darin.K wrote:

 


Excuse my stupidity, where can I find the DocumentBounds property?

 

Thanks

mcduff

0 Kudos
Message 14 of 16
(486 Views)

@mcduff wrote:

@Darin.K wrote:

 


Excuse my stupidity, where can I find the DocumentBounds property?

 

Thanks

mcduff


Don't confuse ignorance with stupidity as only the former can be easily cured...

 

It can be found under the 'Text' submenu of the string control properties.

Message 15 of 16
(481 Views)

@Darin.K wrote:

@mcduff wrote:

@Darin.K wrote:

 


Excuse my stupidity, where can I find the DocumentBounds property?

 

Thanks

mcduff


Don't confuse ignorance with stupidity as only the former can be easily cured...

 

It can be found under the 'Text' submenu of the string control properties.


Thanks!! One last clue, you need to have scripting enabled to see it in case anyone else is reading this.

 

mcduff

0 Kudos
Message 16 of 16
(476 Views)