Exemplo n.º 1
0
        //http://www.swart.ws/2009/03/kiosk-full-screen-wpf-applications.html
        public static System.Windows.Rect GetWindowWorkspace(System.Windows.Window Window)
        {
            var Interop = new System.Windows.Interop.WindowInteropHelper(Window);
            var Handle  = Interop.Handle;

            if (Handle == IntPtr.Zero)
            {
                return(new System.Windows.Rect(0d, 0d, 0d, 0d));
            }

            var MonitorHandle = NativeMethods.MonitorFromWindow(Handle, NativeMethods.MONITOR_DEFAULTTONEAREST);

            if (MonitorHandle == IntPtr.Zero)
            {
                return(new System.Windows.Rect(0d, 0d, 0d, 0d));
            }
            var HandleRef = new HandleRef(Window, MonitorHandle);

            var MonitorInfo = new MONITORINFOEX();

            MonitorInfo.cbSize = Marshal.SizeOf(MonitorInfo);
            if (!NativeMethods.GetMonitorInfo(HandleRef, MonitorInfo))
            {
                return(new System.Windows.Rect(0d, 0d, 0d, 0d));
            }

            return(new System.Windows.Rect(MonitorInfo.rcWork.Left, MonitorInfo.rcWork.Top, MonitorInfo.rcWork.Right - MonitorInfo.rcWork.Left, MonitorInfo.rcWork.Bottom - MonitorInfo.rcWork.Top));
        }
 public static extern bool GetMonitorInfo(HandleRef hmonitor, [In, Out] MONITORINFOEX monitorInfo);