LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transparent frontpanel

Hi,

I'm trying to make the frontpanel, in LabVIEW NXG 5.1, transparent by using the "TransparencyKey" property from the "System.Windows.Forms" assembly. This "should" make the frontpanel transparent if the BackColor = Transparent Key (and selected color not used by any of objects on the frontpanel).
But the problem is that I'm not to familiarized with .NET assemblies and how to set this up properly in LabVIEW NXG...

So far I have tried this approach, but not sure if this is the correct way:

.NET functionPNG.PNGGAC.PNG

 

________________________________________________
"Science is about knowing, while engineering is about doing"
0 Kudos
Message 1 of 3
(1,206 Views)

NXG is built around Windows Presentation Foundation (WPF) rather than Windows Forms, so unfortunately the Form.TransparencyKey won't work. There are WPF's Opacity and OpacityMask properties, but that requires getting access to the front panel canvas as a System.Windows.UIElement class, which isn't exposed on the block diagram.

 

You may have better luck with win32 functions such as those in the attached VI (it can be imported into NXG with the code conversion utility). I did try running the attached VI against NXG, but it didn't seem to work. It found a valid window reference, but the transparency setting didn't have any effect. I suspect it's because it uses SetLayeredWindowAttributes, where it should probably use UpdateLayeredWindow. See this blog post for details on how WPF handles transparency.

0 Kudos
Message 2 of 3
(1,164 Views)

I see... 🤔
I have tried the win32 approach, which works fine in LabVIEW 2020, but not in LabVIEW NXG.

 

Here is the block diagram:

Block diagram.PNG

 

With the following "Shared Library Interface:

user32.PNG

________________________________________________
"Science is about knowing, while engineering is about doing"
0 Kudos
Message 3 of 3
(1,083 Views)