SurfaceWindow WPF奇怪的问题 [英] SurfaceWindow WPF strange problem

查看:85
本文介绍了SurfaceWindow WPF奇怪的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经说明了SurfaceWindow的一个奇怪的行为,也许是一个bug。

I've encountred a strange behavior of the SurfaceWindow, perhaps a bug.

我的应用程序正在跨越多个监视器。在应用程序的开始我将主窗口MinWidth和MinHeight设置为计算机桌面的虚拟化宽度和高度。

My Application is spanning multiple monitors. At the start of the application I'm setting the main window MinWidth and MinHeight as the virtualized width and height of the computer desktop.

在常规Window WPF中,它的行为符合预期,我把它替换为SurfaceWindow,我只能看到渲染的主要montior,而spaec的其余部分只是透明的。当我窥探应用程序时,一切看起来都正确,窗口的AcutalWidth和AcutalHeight
设置正确。

While in the regular Window WPF it behaves as expected, when I replace it to the SurfaceWindow, I can see only the main montior rendered while the rest of the spaec is just transparent. When I snoop the app, everything looks right, AcutalWidth and AcutalHeight of the window are set correctly.

任何人都可以对此进行遮挡?

Anyone can shade a light on this?

谢谢

Ariel

推荐答案

我觉得这是一个Win32 HWind问题...

I have a feeling this a Win32 HWind issue ...

 

使用Win32 API计算可用尺寸:

use Win32 API to calculate the available size:



#region Native Methods


[DllImport("user32.dll")]


static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);


 


[Serializable, StructLayout(LayoutKind.Sequential)]


public struct RECT


{


  public int Left;


  public int Top;


  public int Right;


  public int Bottom;


 


  public RECT(int left_, int top_, int right_, int bottom_)


  {


    Left = left_;


    Top = top_;


    Right = right_;


    Bottom = bottom_;


  }


 


  public int Height { get { return Bottom - Top; } }


  public int Width { get { return Right - Left; } }


  public Size Size { get { return new Size(Width, Height); } }


 


  public Point Location { get { return new Point(Left, Top); } }


 


  // convert to a System.Drawing.Rectangle


  public Rect ToRectangle()


  { return new Rect(Left, Top, Right, Bottom); }


 


  public static RECT FromRectangle(Rect rectangle)


  {


    return new Rect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom);


  }


 


  public override int GetHashCode()


  {


    return Left ^ ((Top << 13) | (Top >> 0x13))


      ^ ((Width << 0x1a) | (Width >> 6))


      ^ ((Height << 7) | (Height >> 0x19));


  }


 


  #region Operator overloads


 


  public static implicit operator Rect(RECT rect)


  {


    return rect.ToRectangle();


  }


 


  public static implicit operator RECT(Rect rect)


  {


    return FromRectangle(rect);


  }


 


  #endregion


}


 


public static RECT GetClientRect(IntPtr hWnd)


{


  RECT result = new RECT();


  GetClientRect(hWnd, out result);


  return result;


}


#endregion


这篇关于SurfaceWindow WPF奇怪的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆