選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

WindowHelper.cs 797 B

8ヶ月前
1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace DamnOverSharp.Helpers
  4. {
  5. internal static class WindowHelper
  6. {
  7. [DllImport("user32.dll")]
  8. private static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
  9. public struct Rect
  10. {
  11. public int Left { get; set; }
  12. public int Top { get; set; }
  13. public int Right { get; set; }
  14. public int Bottom { get; set; }
  15. }
  16. public static System.Windows.Rect GetWindowRectangle(IntPtr windowHandle)
  17. {
  18. Rect result = new Rect();
  19. GetWindowRect(windowHandle, ref result);
  20. return new System.Windows.Rect(result.Left, result.Top, result.Right - result.Left, result.Bottom - result.Top);
  21. }
  22. }
  23. }