Jump to content

dynamically setting controls' colors


Bab

Recommended Posts

I am wondering why I can’t find the „colors“ property for the control class objects?

If I want to update a Front Panel and switch from the default LabVIEW colors, I need to use the pencil tool and edit all the “parts” of all the controls and indicators. It gets even more tricky when one control “part” has several states with a color each (i.e. the increment and decrement buttons of a digital), then I think the only way is to open the control editor (Customize option), and change each color.

So I NEED to automate this task.

Did anyone ever need to do just that? Is there a way to manipulate controls, and sub-parts of controls?

Maybe any idea in the direction of programmatically manipulating the control editor?

Can I get a reference to a control sub-part (say the frame)?

Thanks,

BaB.

Link to comment

Each class has a different color property. For example, a boolean will have the Colors[4] property where a string control can have colors for the text and colors for the control itself.

What you can do is cast the generic control reference to the specific class of the control and then use its colors properties. You can do this by getting the ClassID property of the control, wiring it into a case structure and using the To More Specific Class primitive inside the case.

I don't know of a list of the class IDs, but there are various tools around the web (and on LAVA) which do this for generic handling of controls (although not neccessarily for the color properties).

There is currently no way to programatically access the subparts of a control or to control the control editor.

Can you give an example of a UI which is so complex that it takes more than a minute or two to color all of it?

Link to comment

QUOTE(Yen @ Dec 4 2007, 06:06 PM)

Each class has a different color property. For example, a boolean will have the Colors[4] property where a string control can have colors for the text and colors for the control itself.

What you can do is cast the generic control reference to the specific class of the control and then use its colors properties. You can do this by getting the ClassID property of the control, wiring it into a case structure and using the To More Specific Class primitive inside the case.

I don't know of a list of the class IDs, but there are various tools around the web (and on LAVA) which do this for generic handling of controls (although not neccessarily for the color properties).

There is currently no way to programatically access the subparts of a control or to control the control editor.

Can you give an example of a UI which is so complex that it takes more than a minute or two to color all of it?

Hi Yen,

I feared I would have such a reply. Jim Kring’s topic Is there a cluster frame color property? indicates the frame color (for a cluster or any other control I would say) is not available programmatically.

I naively supposed that every manual change available with the right mouse click on a control was also available using property nodes…

And to answer your question Yen: your example of a Boolean is one of the control that have a color property, unfortunately it is more an exception that the general case. Let’s look at a simple digital numeric control. When you edit it in the control editor, it has 6 sub-parts: Name Label, Numeric Text, Increment, Decrement, Radix and Frame.

post-9285-1196848000.png?width=400

The first 2 are nice since you can get a reference to it and they belong to the Decoration\Text Class and inherit therefore the colors property programmatically available. The 4 other seem not available at all programmatically. The Increment and Decrement parts are like simple buttons having each 2 states (and thus 2 colors each). The radix has a background and a text color. The frame has also 2 colors.

So you see how many thing you must modify in order to set the colors of one control the way you really want it. If you have many controls – maybe in a settings window with many tabs…

And if you have a rather large application with many Front Panels. It takes quite some time.

If no one know of a way, I guess I’ll be able to automate the coloring of Booleans and Text-Class Objects at least.

I tried to typecast a Digital Numeric into a Decoration:

post-9285-1196848026.png?width=400

but I only get Error 1058 (Specified property not found).

Thanks,

BaB.

Link to comment

QUOTE(Bab @ Dec 5 2007, 04:51 AM)

So you see how many thing you must modify in order to set the colors of one control the way you really want it. If you have many controls – maybe in a settings window with many tabs…

And if you have a rather large application with many Front Panels. It takes quite some time.

If no one know of a way, I guess I'll be able to automate the coloring of Booleans and Text-Class Objects at least.

Are you trying to make a UI where the operator can customize the colors on the fly, or are you trying to automate (script) changes while using the development environment? If you're doing this to speed up making changes in the development environment, consider creating strictly typdefed controls. It takes some up-front planning, but makes changes simpler later on. Place these as needed, then update the typdef once to change all instances.

If your application is going to run on more than one machine or be used by more than one or two operators, you may want to use system colors on your controls, indicators and backgrounds. The UI will then match the OS settings for colors and will behave like larger commercial based apps.

Just an idea...

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.