Winforms在不同环境中的大小不同 [英] Winforms different sizes in different environments

查看:72
本文介绍了Winforms在不同环境中的大小不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,一些使用我的应用程序的人抱怨WinForm的绘制方式有些奇怪.该表单具有一个 splitcontainer ,其中固定了 panel1 .直到今天,我都无法重现他们的问题.

For some time now, a few people who have been using my application has complained about some strange behaviour in how the WinForm is being drawn. The form has one splitcontainer with panel1 being fixed. I have not been able to reproduce their problems, until today.

我刚刚在运行32位版本的Win7企业版的笔记本电脑上安装了该应用程序.(该应用程序在运行64位版本的Win7 ent的计算机上已构建并正常运行.)

I just installed the app on a laptop running a 32 bit version of Win7 enterprise. (app is built and running without problem on my computer running 64 bit version of Win7 ent.)

要查看发生了什么,我将项目文件复制到便携式计算机上,并使用Visual Studio 2012将其打开以查看发生了什么.但是,我不知道该怎么办,这让我感到震惊.

To see what was going on, I copied the project files over to the laptop and opened it with Visual Studio 2012 to see what was going on. However, is has me stunned as I don't know what do do about it.

关于开发者.机器(我的64位win7 ent)机器上,表单(和拆分容器)大小的规格如下:

On the dev. machine (my 64 bit win7 ent), the specifications for the form (and split container) sizes are as follows:

  • 表格高度:383
  • 表格宽度:707
  • 拆分容器的高度:321
  • 已拆分容器宽度:691
  • 分割线距离:380

当我在笔记本电脑上加载项目时,规格更改为:

When I load the project on the laptop, the specifications are changed to this:

  • 表格高度:419
  • 表格宽度:859
  • 拆分容器高度:397
  • 已拆分容器宽度:921
  • 分割线距离:380

现在,我终于可以理解有些人无法以应有的方式查看程序,这让他感到沮丧.

Now I can finally understand the frustration with some people not being able to see the program as how it is supposed to be seen.

在32位计算机上,拆分器部分覆盖了几个按钮,这显然使程序难以使用,因为它们看不到文本.

On the 32 bit machine, the splitter is partly covering a few buttons, which obviously making the program hard to use since they can't see the text.

有什么原因会发生这种情况吗?

Is there any reason why this happens?

我的意思是,如果将原始代码设置为特定的大小值,那么无论程序在何处运行,这不是应该的吗?(考虑到用户当然不调整大小).

I mean, if the original code is set to a specific size value, isn't that how it should be no matter where the program is run? (Given the user doesn't resize of course).

然后最重要的是,有什么方法可以解决这个问题而不必构建两个单独的版本?

And then most importantly, is there any way I can solve this without having to build two separate versions?

推荐答案

他们可以在不同的DPI(每英寸点数)上运行系统,因此这正在改变控件在Windows窗体上的放置和缩放方式.由于缩放选项会影响字体大小.

They could be running their systems at a different DPI (Dots Per Inch), and so this is changing the way the controls are positioned and scaled on the Windows Form due to the scaling options and affect on the font size.

http://discuss.joelonsoftware.com/default.asp?dotnet.12.664790.5

您可以查看控制面板|外观和个性化|显示以查找那些设置:

You can look at Control Panel | Appearance and Personalization | Display to find those settings:

  • 更小-100%= 96 DPI
  • 中等-125%= 120 DPI
  • 更大-150%= 144 DPI

如果DPI起作用并且需要适当调整,您可以查看WinForms Scaling选项.

You can look into the WinForms Scaling options if it's the DPI having an effect and what to adjust appropriately.

这篇关于Winforms在不同环境中的大小不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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