How to revert the transparent window of WPF.

Sunil A M 171 Reputation points
2022-08-12T14:43:22.7+00:00

HI Team,

I have used a below technique to create a transparent(click thru) window in WPF.
https://stackoverflow.com/questions/2842667/how-to-create-a-semi-transparent-window-in-wpf-that-allows-mouse-events-to-pass

Could you please tell me how to revert the above functionality on some event(on the fly).
(Need code to Revert the transparent window to normal window on some event).

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,665 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,191 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
760 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,446 Reputation points
    2022-08-12T15:31:24.813+00:00

    You can remove the WS_EX_TRANSPARENT extended style :

     int nExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);  
     SetWindowLong(hWnd, GWL_EXSTYLE, (nExStyle & ~WS_EX_TRANSPARENT));  
    
    0 comments No comments

0 additional answers

Sort by: Most helpful