根据屏幕分辨率自动管理窗口大小. [英] Auto Window size Management according to Screen Resolutions.

查看:75
本文介绍了根据屏幕分辨率自动管理窗口大小.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2012.我已经在Visual Basic中创建了一个应用程序(Windows商店应用程序).
但是问题是当我以高分辨率运行该应用程序时,内容会变小..
我想知道如何根据分辨率调整内容的大小..

I m using VS2012. I have created an application in visual basic (windows store application).
but the problem is when i run that application in high resolution the content becomes smaller..
i want to know how to resize content according to resolutions..

推荐答案

可能有不同的答案.这取决于应用程序的目的和一件非常基本的事情:是否需要主应用程序窗口是否可调整大小.

在最简单的情况下,您无需执行任何操作.想一想为什么用户购买更大的显示器.首先,让我们考虑一个简单的固定大小(以像素为单位)的窗口.您所描述的情况接近以下情况:假设您的应用程序在某些小型显示器上占据了四分之一的屏幕.它怎么会变成更大的呢?用户可能会购买一台更大的显示器,通常,如果显示器更大,那么该显示器上的像素大小也不会太大-随着技术的进步,它甚至可以变得更小.它只有更多的像素.这样,您的应用程序的绝对尺寸会变小(像素数是相同的),或者只是相对变小:现在它不需要占用四分之一的屏幕,但甚至可能只占其的1/16.

如果您认为用户希望应用程序使用相同尺寸的显示器,则绝大部分问题都是错误的.用户可能希望将其缩小,以在同一屏幕上显示更多应用程序.换句话说,与旧显示器相比,用户确实需要一次查看功能总数.

无论如何,如果您希望调整窗口的大小以使其占据屏幕的同一部分,则可以始终执行此操作,因为您始终可以获得屏幕的大小.在WPF中,您将在Forms中使用System.Windows.SystemParameters.PrimaryScreenWidthSystem.Windows.SystemParameters.PrimaryScreenHeight-类System.Windows.Forms.为什么?您还应该了解,不同的显示器具有不同的宽高比.好吧,我必须承认,在少数情况下,这种方法很有意义.不过很少.

现在,使应用程序可调整大小是个好主意,因此用户可以决定应用程序的方便大小或最大化.如果您随着窗口的增加一次提供越来越多的可见细节,则特别值得.窗口布局应流畅.您需要很好地设计应用程序布局,因此它适用于各种尺寸.这意味着,没有绝对的定位,没有字体大小的假设,一切都会自动调整大小.有关更多详细信息,请参阅我过去的答案:
当屏幕分辨率改变时,Zom Out发生故障 [ ^ ],
GUI外观-C#.Net [如何停靠按钮,以便它可以使用以下格式进行调整 [
There can be different answers. It depends on the purpose of the application and one very basic thing: if you need the main application windows resizeable or not.

In most simple case, you don''t need to do anything. Just think why a user buys a bigger monitor. To start with, let''s consider a simple fixed-size (in pixels) window. What you describe is close to the following situation: let''s say, your application takes a quarter of screen on some small monitor. How can it end up in a bigger one? The user might buy a bigger monitor, and, typically, the pixel size on this monitor is not much bigger, if its is bigger at all — it can be even smaller as technology improves.. It just has more pixels. This way, your application becomes smaller in absolute sized (number of pixels is the same), or only relatively: now it does not take a quarter of the screen, but it may take even 1/16 of it.

If you think that the user wants the application to take the same quarter-size of the monitor, in absolute majority of questions, you are wrong. The user would want to have it small, to show more application in the same screen. In other words, the user really needs to see the total number of features at once, compared to the old monitor.

Anyway, if you want to resize the window so it would take the same part of the screen, you can always do it, because you can always get the screen size. In WPF, you would use System.Windows.SystemParameters.PrimaryScreenWidth and System.Windows.SystemParameters.PrimaryScreenHeight, in Forms — the class System.Windows.Forms. By why? You should also understand that different monitors have different aspect ratios. Well, I must admit there are some rare cases when such approach makes sense. Rarely, though.

Now, it''s a good idea to make the application resizeable, so the user decides on the convenient size of it, or maximize. It pays of especially well if you provide more and more detail viewable at once as the window grow. The window layout should be fluid. You need to design the application layouts nicely, so it will work well for a wide range of sizes. It means, no absolute positioning, no assumption of font size, everything is resized automatically. For more detail, please see my past answers:
Zom Out malfunctions when Screen resolution changes[^],
GUI Apperance - C#.Net[^],
how to dock button so that it can adjust with the form[^].

—SA


这篇关于根据屏幕分辨率自动管理窗口大小.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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