let's take notepad.exe for example, is it possbile to create a same size transparent window on top of notepad main window without affecting user experience?
1 Answers
is it possbile to create a same size transparent window on top of notepad main window
It is pretty easy to FindWindow()
the Notepad window, then GetWindowRect()
its position and dimensions, and then place your custom window at the same location and size. You can use the WS_EX_LAYERED
style with SetLayeredWindowAttributes()
or UpdateLayeredWindow()
to apply transparency/translucency to your window as needed.
Or, you might consider creating a layered window as a direct child of Notepad's window (Windows 8+ only), see:
Creating a Transparent Child window on top of non-transparent Parent Window ( win 32 )
without affecting user experience?
Not so easily, no. You might be tempted to use the WS_EX_TRANSPARENT
window style, but be aware that WS_EX_TRANSPARENT is a lie, or at least not the entire truth (also this). Or you might be tempted to handle WM_NCHITTEST
to return HTTRANSPARENT
, but that gets complicated (also this).

- 555,201
- 31
- 458
- 770
-
2*"then `GetWindowRect()` its position and dimensions"* - Sounds simple, right? Well, yes. If you are on Windows XP. With Vista and up you have to account for the DWM's idiosyncrasy of attributing a window's drop shadow area to the window area. Add several different kinds of DPI-awareness into the mix and you'll wind up with a complex implementation that frequently returns the wrong values nevertheless. – IInspectable Oct 10 '20 at 08:25