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.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Transparent Main Panel?

Hi,

 

Does anyone know if this is possible?  I'd ike to make an application that is transparent and runs on top of a 3rd party application.  I would plot data in my application over top of the other app.

 

Do-able or not?  I've looked around and don't see a way of doing it.

 

Thanks,

 

Dave

0 Kudos
Message 1 of 3
(4,857 Views)

Hello Dave!

 

Unfortunately there isn't a direct way of making a LabWindows/CVI panel trasparent, by using a predefined panel attribute.

 

However, here is a workaround to make your panel transparent, using Win32 API:

  1. #include <windows.h> in your source code.
  2. Get the window handle (HWND) of the panel, using the ATTR_SYSTEM_WINDOW_HANDLE panel attribute:
    HWND hwnd;
    GetPanelAttribute (panelHandle, ATTR_SYSTEM_WINDOW_HANDLE, &hwnd);
  3. Configure windows layering: 
    SetWindowLong ((HWND)hwnd, GWL_EXSTYLE, GetWindowLong((HWND)hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
  4. Enable window transparency (see MSDN😞
    // Set the alpha for transparency: 0 is transparent and 255 is opaque.
    double transparency = 50; // Set transparency to 50%.
    double alpha = transparency * (255.0 / 100);
    SetLayeredWindowAttributes ((HWND)hwnd, 0, alpha, LWA_ALPHA);

Hope this helps!

- Johannes

Message 2 of 3
(4,780 Views)

Hi Johannes,

 

That was exactly what I was looking for.  THANKS!

 

Just had to change HWND hwnd; to int HWND; in order to get the right variable type for GetPanelAttribute(), which works OK since it's cast to HWND below that.

 

Thanks again!

 

Dave

0 Kudos
Message 3 of 3
(4,747 Views)