From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Control resizing

Solved!
Go to solution

I think that I know the answer to this already ( i.e. No ) but wanted to check...

 

Is it possible to create a custom control such that when it is resized any graphics remain the same size?

i.e. something along the lines of the following image

buttons.PNG

 

Why?

I have some buttons with icons on. The buttons are dynamically resized to reflect the user's configuration. Resizing the buttons messes up the icons, and for continuity I wouldn't wish to resize the icons anyway.

I could just position a picture over the button in the correct place, but then the user can't 'click through' the image to switch the button and the code would get pretty messy.

The only other option I can think of is to have all permutations of buttons and sizes ready and then show/hide as appropriate - again, that could get mucky.

 

Any ideas, tips or hints?

(In case it makes a difference I'm using V8.5)

 

Thanks,

Ian

0 Kudos
Message 1 of 14
(3,055 Views)

Ian,

   I'm not sure if this will work with a custom button, but you might try creating property nodes for your buttons then setting the size of the pictures to a constant. I've attached a very basic example of holding the text size constant on a stop button when you resize the button.

 

--Ryan

0 Kudos
Message 2 of 14
(3,047 Views)

Thanks Ryan,

So far I haven't found a property node for boolean buttons which provides access to images. For example, graphs have plotimages.back/front/middle - this kind of thing would be handy if it existed for booleans.  Property nodes would work for picture indicators on their own, but that takes me back to the 'click through' problem when they are positioned over a button.

Text size isn't really an issue as changing the size of a control doesn't affect the text within it.

 

I've also (optimistically) tried flattening an image to a string and writing that to the Boolean Text.Text property node to see if it would display as an image - unsurprisingly it didn't!

 

Ian

0 Kudos
Message 3 of 14
(3,043 Views)
Solution
Accepted by topic author _Ian_

You could make the button transparent and add a picture behind it. Then when you resize the button you are not really changing the picture. You may have to move it to keep it in the center of the button but that is doable.

Tim
GHSP
Message 4 of 14
(3,041 Views)

That sounds like a plan! I'll give it a go and post back with what I get.

Thanks Tim.

 

Ian

0 Kudos
Message 5 of 14
(3,039 Views)

This pretty much does what I was hoping - its not quite as refined as I was hoping, although with a few more event cases I could add mouse-over behaviour etc.

 

Comments or suggestions for improvements welcome (particulary on how to change my graphics to a 'disabled and grayed' appearance)

 

Thanks again,

Ian

 

 

0 Kudos
Message 6 of 14
(3,024 Views)

Would there be a way to decrease the transparency of the button slightly when pressed that way you get the darker appearence?

 

--Ryan

0 Kudos
Message 7 of 14
(3,014 Views)

Might work.

I realised that I can of course simulate disabled and grayed in exactly the same way as I made the original pictures, namely by setting some controls to that state and copying their appearance into picture constants. Its a bit laborious and will end up with a few extra property nodes floating around but will probably be worth it in the long run in order to get a vaguely appealing UI.

0 Kudos
Message 8 of 14
(3,009 Views)

I had a little more fun with it than you did. Here you can chage the size of the button and it will change sizes to any size not just four. Let me know what you think.

Tim
GHSP
0 Kudos
Message 9 of 14
(2,993 Views)

Small Change

Tim
GHSP
0 Kudos
Message 10 of 14
(2,991 Views)