LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can a Color Box display the transparent color [16777216]?

I was trying to force a Color Box to display the transparent color [16777216 = "2 to the 24th"], but I didn't have much luck.

Instead of displaying transparent, the Color Box wanted to paint a replica of the coloring tool's "transparent" icon, which is a small "T" on a white background.

Is it possible to make a Color Box display the transparent color?

[See attached VI.]
0 Kudos
Message 1 of 10
(5,152 Views)
I do not think you can.

If you really need to make it look like it is transparent, you can hide the control when its value is equal to "T".

Then of course you can not click on it once it is hidden...

The attached code is a quick hack that may be useful (LV 7.0).

I use a transparent boolean behind the color box to make it look transparent and re-direct key-focus when the transparent boolean is is clicked. Because the boolean is behind the color box you usually only see the color box.

There is an obvious draw back that if the color was transparent, you have to clcik it twice.

What do you think?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 10
(5,140 Views)
Yeah, but I think the "Visible" property is more or less the same thing as "Hide Control/Show Control", and the transparent color is a little different than that.

For instance, if you put a transparent "control" over a functioning control, then the transparent "control" will e.g. intercept all the end-user's mouse clicks, and prevent the end-user from damaging the functioning control with some new setting [for more on that, see this thread].

I had thought that it might be possible to use a Color Box control in this sort of scenario, but apparently they decided to use the extra eight bits {24, 25, 26, 27, 28, 29, 30, 31} in the U32 for something other than transparency.

Unless maybe there's some special combination of those extra bits that means "transparent". But I guess that's more or less the entire purpose of this thread.
0 Kudos
Message 3 of 10
(5,118 Views)
Like I said I do not think you can do that.

"I had thought that it might be possible to use a Color Box control in this sort of scenario"

I am curious, why is a color box more useful than a boolean set as transparent?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 10
(5,122 Views)
> I am curious, why is a color box more useful than a boolean set as transparent?

Well, if you're trying to do the "intercept mouse clicks" thing, then you need to use something transparent. "Transparent" is a color [more or less - true colors range from 0 to 2^24 -1, whereas "Transparent" is 2^24 itself], so your first thought is obviously "Color Box!!!" - and it's even got the extra bits that should allow for that "Transparent" flag. Unfortunately, as we seem to have found, it just doesn't want to work [although I'm tempted to write a quick script to test all 256 cases of the eight extra bits, and maybe even the 257th value, 2^32, for good measure].

It's real easy to make "Decorations" be transparent on the front panel, but "Decorations" are even worse than Global Variables - there doesn't seem to be any way to make them appear on a block diagram, so there's no natural "trace" or "imprint" in the block diagram code that would remind you that you slapped a transparent control on top of a visible control [and that's why the end-user's mouse clicks no longer work].

The problem with the other "square-ish" controls, like Boolean "stop" buttons, is that they come with all sorts of added functionality. I suppose you could take a Boolean "stop", hide its label & its Boolean text, set it to disabled, and paint it transparent, but that seems like using a hammer for a job that really ought to be performed by a screwdriver.
0 Kudos
Message 5 of 10
(5,111 Views)
Well just for the record it appears it is possible to make a color box transparent.

But...

Once you have,it is transparent all of the time!

See attached transparent color box.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 10
(5,106 Views)
I see a couple of ways around this.

If you're using events to capture activity on the front panel, you can choose to ignore the click in code, thus making any "hiding" of the control unneccessary. The code can of course have any kind of link with the rest of your program so that the accept/reject conditions are kept up to date from the current state of your code.

Use an indicator instead of a control.

Set the "Disabled" value of the control you wish to "hide". You can make the control unresponsive to clicks without graying it out or really hiding it. I think this should also do it for you.

Any reason why it must be something floating over the control (Which plays havok with the front panel graphic update routines by the way).

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 7 of 10
(5,099 Views)
> Well just for the record it appears it is possible to make a color box transparent.

Okay, that's pretty cool. How'd you do it? Also, your transparent "color" reports as being 0 [zero], which should be black. [Frankly, this strikes me as something of a bug...] And your Color Box does report as Visible.

Or maybe it's only reporting the first 24 bits of your color as black, and omitting some values in the other eight bits [such as, maybe {1, 1, 1, 1, 1, 1, 1, 1}???].

I added a couple of other values [2^32 - 1, and (2^32 - 1) - (2^24 - 1), which should have 0 in the low 24 bits, and all 1's in the high eight bits], but I couldn't get it to take a value of 2^32. [I don't know how to do long ints in LabVIEW - I seem to recall that you can't.]

Anyway, when I get some time [maybe tonight], I'll write a script to display all 256 possible values of the top eight bits.

But in the meantime, do tell how you got the Color Box to display transparent.

Thanks! Gotta run.
Message 8 of 10
(5,087 Views)
Well I am not exactly sure.

I started a search (that I never finished) on "color" looking for Greg McKaskle answers (I seem to remember that he once revealed the function of the low order bits(s) of the highest order byte of the color values.

In that search I read him saying that the classic controls (when customized) could export their images as meta files.

I did this and then pasted it into a Word doc. Used the picture editor to set the transparency as 100% and then copied the picture.

Back in the control editor I imported the picture from the clip board.

Well that is basicaly what I did, but, becuase I had the control set for "T" I did not notice when exactly the transparent image got inserted!

I also tried using PowerPoint at first and that may have worked as well.

This is the first time I have managed to get a transpaert image into a control! I will have to play with this some more because I have had a need to create tranparent regions in control images.

If you figure a step by step to do this, please share.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 10
(5,084 Views)
Thank you so much for posting the transparent color value. I am using a slide with multiple sliders and wanted to "hide" the sliders until they were needed. I have been racking my brain trying to figure out how to do this when I ran across your posts. First I set the FG and BG color to the transparent color value. A loop was created to read the slider value and change to the appropriate color.
0 Kudos
Message 10 of 10
(5,025 Views)