01-23-2021 05:52 AM - edited 01-23-2021 05:53 AM
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:
01-23-2021 09:50 AM - edited 01-23-2021 09:56 AM
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.
01-25-2021 08:57 AM
I see... 🤔
I have tried the win32 approach, which works fine in LabVIEW 2020, but not in LabVIEW NXG.
Here is the block diagram:
With the following "Shared Library Interface: