Change User32 Extended Styles on Windows #114

Closed
opened 2026-01-29 16:31:18 +00:00 by claunia · 2 comments
Owner

Originally created by @fatalmuffin on GitHub (Jan 31, 2018).

Originally assigned to: @GregorBiswanger on GitHub.

Hello. I am writing an app which relies on an external C# dll to run some user32 interop functions.
It's working quite well except I'm not allowed to subclass in C# .net and therefore cannot change windows styles / extended styles for my Electron window.

If you're wondering what I'm talking about, check here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx

My interop dll is parenting the electron window to another window, which works fine, except the window gets a black backdrop instead of it's normal transparency.

I figured out (through Winspectorspy utility) that it needs the WS_EX_TRANSPARENT style and must not have the WS_EX_COMPOSITED style applied to the window.

My question, before I jump into creating an umanaged C++ wrapper so I can subclass the window (huge pain in the ass), is there any way other way I could change the electron window's extended styles?

Originally created by @fatalmuffin on GitHub (Jan 31, 2018). Originally assigned to: @GregorBiswanger on GitHub. Hello. I am writing an app which relies on an external C# dll to run some user32 interop functions. It's working quite well except I'm not allowed to subclass in C# .net and therefore cannot change windows styles / extended styles for my Electron window. If you're wondering what I'm talking about, check here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx My interop dll is parenting the electron window to another window, which works fine, except the window gets a black backdrop instead of it's normal transparency. I figured out (through Winspectorspy utility) that it needs the WS_EX_TRANSPARENT style and must not have the WS_EX_COMPOSITED style applied to the window. My question, before I jump into creating an umanaged C++ wrapper so I can subclass the window (huge pain in the ass), is there any way other way I could change the electron window's extended styles?
claunia added the question label 2026-01-29 16:31:18 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Jan 31, 2018):

Hey @fatalmuffin,

you could change everything, the BrowserWindow-Object offers.

You find the BrowserWindow documentation here:
https://github.com/electron/electron/blob/master/docs/api/browser-window.md

In Electron.NET here:
Electron.WindowManager.BrowserWindows.First();

Don´t forget your P/Invoke code is only for windows.
Use the .NET Core code for determine the Operating System:

bool isWindows = System.Runtime.InteropServices.RuntimeInformation
                                               .IsOSPlatform(OSPlatform.Windows)

I hope my answer helps you.

@GregorBiswanger commented on GitHub (Jan 31, 2018): Hey @fatalmuffin, you could change everything, the BrowserWindow-Object offers. You find the BrowserWindow documentation here: https://github.com/electron/electron/blob/master/docs/api/browser-window.md In Electron.NET here: `Electron.WindowManager.BrowserWindows.First();` Don´t forget your P/Invoke code is only for windows. Use the .NET Core code for determine the Operating System: ``` bool isWindows = System.Runtime.InteropServices.RuntimeInformation .IsOSPlatform(OSPlatform.Windows) ``` I hope my answer helps you.
Author
Owner

@fatalmuffin commented on GitHub (Feb 10, 2018):

Hey! Sorry for the lack of a response, I found out I was actually wrong about the reason why I was having issues. Turns out after adding the extended styles I needed, I had to refresh to parent window (in this case the desktop) done with a pinvoke SystemParametersInfo. Thanks for the reply though!

@fatalmuffin commented on GitHub (Feb 10, 2018): Hey! Sorry for the lack of a response, I found out I was actually wrong about the reason why I was having issues. Turns out after adding the extended styles I needed, I had to refresh to parent window (in this case the desktop) done with a pinvoke SystemParametersInfo. Thanks for the reply though!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#114