first time writing a question here, this site helped me a lot thru the years, thanks !
DwmGetWindowAttribute
doesn't return exact rectangle where the window is and its's size using this code :
[DllImport("User32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out RECT pvAttribute, int cbAttribute);
Intptr m_current_active_window_handle = GetForegroundWindow();
DwmGetWindowAttribute(m_current_active_window_handle, DwmWindowAttribute.DWMWA_EXTENDED_FRAME_BOUNDS, out RECT __rv, Marshal.SizeOf(typeof(RECT)));
I want to get capture of active/foreground window at specific occasions and I tested on 2 different versions of windows and still not working with my setup..
Dual 1440p monitors (both 100% scaling)
Windows 10 Enteprise LTSC 2019
Windows 10 Pro (19042)
I have disabled animations during minimizie/maximize, dropshadow under windows
here is what I get and sometimes it returns me window with 2 extra pixels on top and non on the other 3 sides which have black border..
ps. ignore white region around the window, it is purposely there to show extra stuff around 'window':