如何衡量表单的尺寸?

时间:2011-06-01 08:58:01

标签: wpf winforms resolution

我刚为客户设计了一个商业信息仪表板。最初的设计是针对1280x1024的屏幕分辨率,但现在看来客户的分辨率为1024 x 768。这个BI表单是MDI接口的子窗口,因此有一个标题和状态栏,这意味着如果应用程序是完整的,那么它占用1024/768 - Windows任务栏和我的表单有这个可用的大小减去大小MDI应用程序的标头和状态栏。我可以处理这个,但我想让应用程序专门针对最常用的屏幕大小进行定制,它发生的是他的。

是否有人知道注册表中的任何地方或任何工具等可以告诉我正在查看窗口/表单的大小?

干杯 添

1 个答案:

答案 0 :(得分:0)

我没有做任何MDI的事情,但从快速的解释中我相信这可能会有所帮助。我将下面的内容写成了儿童表格。

label1.Text = this.Parent.ClientRectangle.Width.ToString() + "x" + this.Parent.ClientRectangle.Height.ToString();

它似乎返回了MDI父级的内部大小。当我添加更多工具条和状态条时,高度降低了。

希望这有帮助。

编辑: 奇怪的是,这似乎没有带回父表格名称(嗯谜题)。:

label1.Text = this.Parent.Name;

编辑2: 但这样做(注意第二个家长 - 现在我很困惑):

label1.Text = this.Parent.Parent.Name;

编辑3: 好的,经过几次测试......

1. this.Parent.ClientRectangle  //this seems to be the size in the MDI form - NOT including toolbars/statusstrips/menustrips etc.

2. this.Parent.Parent.ClientRectangle  //Having TWO parents seems to be the main MDI size - no matter how many strips added in this seems to return the size - not including the window titlebar.

编辑道歉。

相关问题