LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically determine scrollbar width of a front panel control?

Fundamentally, I would like to discard clicking in the body of a STRING indicator, but allow the user to use the vertical scrollbar. When I discard clicks in a "Mouse Down?" event, it also prevents scrollbar use.

 

I haven't found a simple way to do that, so I hard-coded a scrollbar width of 12 pixels and discarded clicks that were >12 pixels to the right of the control's right bound. But I hate hard-coding constants like that; it would be much better if I could programmatically determine the width of the scrollbar.

 

Any suggestions for determining the scrollbar width? Alternatively, any superior methods for discarding clicks in a STRING indicator while still giving access to the scrollbar?

0 Kudos
Message 1 of 14
(4,663 Views)

Set the Selection to 0,0 on any keystroke or mouse down/up event... though it's still not super elegant.

CTA, CLA, MTFBWY
0 Kudos
Message 2 of 14
(4,660 Views)

When I want something quick and dirty I'll just slap a transparent picture control over the top of the area I want to block from clicks.  Grouping the controls can help when you move things around.  In this case cover the text portion of the indicator, but not the scrollbar region.  No math, no code.

 

Edit:  forgot to mention the other added bonus, no cursor changes which give the false impression that you can click in the first place.

0 Kudos
Message 3 of 14
(4,655 Views)

Darin, I had exactly the same thought, but I ran into the same basic problem: I don't know how wide the scrollbar is, and therefore can't distinguish between total control width and scrollbar width. Unless I'm misunderstanding your suggestion?

 

EDIT: I should clarify that the size of the string indicator changes dynamically, depending on how the Dialog VI is called.

0 Kudos
Message 4 of 14
(4,650 Views)

See, this is why we keep these guys around. Simple and elegant 🙂

CTA, CLA, MTFBWY
0 Kudos
Message 5 of 14
(4,646 Views)

I may be missing something, you simply draw the picture control to be the proper size.

 

 

0 Kudos
Message 6 of 14
(4,645 Views)

I added an edit in the original comment, but basically the string indicator gets resized depending on how the dialog sub-VI is called. I do all the control arrangements dynamically.

 

I'd also be worried about the width of the scrollbar varying depending on the computer it's deployed on. Wouldn't that potentially mess with the transparent control alignment?

0 Kudos
Message 7 of 14
(4,643 Views)

How are you resizing?  This method works fairly well if you scale objects with the pane.  If you are forced to do math, I think you will always have frames and other offsets to worry about.  One other suggestion is to stick to the system string, I think it is the cleanest.

 

0 Kudos
Message 8 of 14
(4,637 Views)

Basically, it's a generic "prompt" dialog. I load whatever text I want, sometimes just a short warning message, sometimes multiple paragraphs.

 

After the text is loaded into the Message string control, I call a Size to Text Invoke node.

 

Then I check the height of the string control. If it exceeds a certain threshold (currently 75% of the monitor vertical resolution) then I size it down to the max limit and toggle the vertical scrollbar on.

 

Let me know if any of that was unclear or if you need more info.

0 Kudos
Message 9 of 14
(4,634 Views)

I see, turning the scrollbar on and off will be a bit of an issue.  I suppose you could either dynamically size the picture control, or systematically calculate the click coordinates, either way you are going to be stuck with a fudge factor I think.  It should be fixed since you are dealing with pixels, unless you also allow the width to scale with pane size.  There are some properties with scripting to get the text bounds, but none of them give you exactly what you would want (as far as I know), and you will simply have different constant offsets.

0 Kudos
Message 10 of 14
(4,628 Views)