11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . IO ;
35using System . Text ;
46using System . Drawing ;
57using System . Drawing . Imaging ;
68using System . Diagnostics ;
79using System . Runtime . InteropServices ;
810using System . Management ;
9- using System . Linq ;
10- using System . IO ;
1111using mshtml ;
1212using WindowTextExtractor . Native ;
1313using WindowTextExtractor . Extensions ;
@@ -58,6 +58,7 @@ public static WindowInformation GetWindowInformation(IntPtr hWnd)
5858 var realWindowClass = RealGetWindowClass ( hWnd ) ;
5959 var hWndParent = NativeMethods . GetParent ( hWnd ) ;
6060 var size = GetWindowSize ( hWnd ) ;
61+ var clientSize = GetWindowClientSize ( hWnd ) ;
6162 var placement = GetWindowPlacement ( hWnd ) ;
6263 var threadId = NativeMethods . GetWindowThreadProcessId ( hWnd , out var processId ) ;
6364 var process = GetProcessByIdSafely ( processId ) ;
@@ -86,8 +87,18 @@ public static WindowInformation GetWindowInformation(IntPtr hWnd)
8687 windowDetailes . Add ( "Window Handle" , $ "0x{ hWnd . ToInt64 ( ) : X} ") ;
8788 windowDetailes . Add ( "Parent Window Handle" , hWndParent == IntPtr . Zero ? "-" : $ "0x{ hWndParent . ToInt64 ( ) : X} ") ;
8889 windowDetailes . Add ( "Window Placement" , placement . showCmd . ToString ( ) ) ;
89- windowDetailes . Add ( "Window Size" , $ "{ size . Width } x { size . Height } ") ;
90-
90+ windowDetailes . Add ( "Window Size" , $ "{ size . Width } x{ size . Height } ") ;
91+ windowDetailes . Add ( "Window Client Size" , $ "{ clientSize . Width } x{ clientSize . Height } ") ;
92+
93+ try
94+ {
95+ var bounds = GetFrameBounds ( hWnd ) ;
96+ windowDetailes . Add ( "Window Extended Frame Bounds" , $ "{ bounds . Top } { bounds . Right } { bounds . Bottom } { bounds . Left } ") ;
97+ }
98+ catch
99+ {
100+ }
101+
91102 try
92103 {
93104 windowDetailes . Add ( "Instance" , $ "0x{ process . Modules [ 0 ] . BaseAddress . ToInt64 ( ) : X} ") ;
@@ -294,6 +305,13 @@ private static Rect GetWindowSize(IntPtr hWnd)
294305 return size ;
295306 }
296307
308+ private static Rect GetWindowClientSize ( IntPtr hWnd )
309+ {
310+ Rect size ;
311+ NativeMethods . GetClientRect ( hWnd , out size ) ;
312+ return size ;
313+ }
314+
297315 private static WINDOWPLACEMENT GetWindowPlacement ( IntPtr hWnd )
298316 {
299317 var placement = new WINDOWPLACEMENT ( ) ;
@@ -302,6 +320,34 @@ private static WINDOWPLACEMENT GetWindowPlacement(IntPtr hWnd)
302320 return placement ;
303321 }
304322
323+ private static Rect GetSizeWithFrameBounds ( IntPtr hWnd )
324+ {
325+ Rect size ;
326+ if ( Environment . OSVersion . Version . Major < 6 )
327+ {
328+ NativeMethods . GetWindowRect ( hWnd , out size ) ;
329+ }
330+ else if ( NativeMethods . DwmGetWindowAttribute ( hWnd , NativeConstants . DWMWA_EXTENDED_FRAME_BOUNDS , out size , Marshal . SizeOf ( typeof ( Rect ) ) ) != 0 )
331+ {
332+ NativeMethods . GetWindowRect ( hWnd , out size ) ;
333+ }
334+ return size ;
335+ }
336+
337+ private static Rect GetFrameBounds ( IntPtr hWnd )
338+ {
339+ var withMargin = GetSizeWithFrameBounds ( hWnd ) ;
340+ var size = GetWindowSize ( hWnd ) ;
341+ return new Rect
342+ {
343+ Left = withMargin . Left - size . Left ,
344+ Top = withMargin . Top - size . Top ,
345+ Right = size . Right - withMargin . Right ,
346+ Bottom = size . Bottom - withMargin . Bottom
347+ } ;
348+ }
349+
350+
305351 private static Process GetProcessByIdSafely ( int pId )
306352 {
307353 try
0 commit comments