如何将对话框调整为屏幕分辨率? [英] How to adjust dialog to screen resolutions?

查看:237
本文介绍了如何将对话框调整为屏幕分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个基于模态对话框的应用程序,分辨率为1152x864.当我以其他分辨率运行此窗口时,该窗口将被截断.
如何调整对话框,使其以可调整的分辨率工作,而以不同的分辨率运行时却不会截断窗口.

I have a developed a modal dialog based application in 1152x864 resolution. when i run this in another resolution the window gets truncated.
How to adjust the dialog so that it works adjustable with the resolution with out truncating the windows display when run in the different resolution.

推荐答案

什么叫超人",从技术上讲是正确的,但是...您应该为您的应用程序考虑更好的GUI设计,因为...它不符合可用性要求.

我要问自己的第一件事是为什么对话框如此之大.
是因为它是所必需的吗?如果是,则您的应用程序必须也不能在小于所需大小的屏幕上运行:您应在发行说明中声明,警告用户不支持在较小的设备上使用该应用程序,因为...不支持"!

如果否,那么您不应该假设设备广告的大小(如果用户使用的设备较宽)就不做任何假设,而是可能不是窗口更宽而是窗口很多.您的设计应占用对话框所需的最小空间,以便可以使用.
如果有太多的空白空间或非常宽的控件,用户将永远无法完全填满,请减少它们.
如果存在关联性差"的控件(从某种意义上来说,它们表示的内容并不相互依赖),则它们可以位于不同的对话框中,可以表示为容器的页面 >选项卡式窗口.

通常,将对话框设计为宽至800x600(在极端情况下为1024 x 800)是一个设计不良的对话框. 独立于屏幕的宽度(以像素为单位).

原因是屏幕的密度被定义为允许从固定距离(通常为50到80厘米)观察屏幕.使用正常的眼睛分辨率,可以达到96dpi的密度.

拥有1920或更宽屏幕的用户(如果坐在距屏幕80厘米处)无法完全聚焦"在屏幕上:他的注意力将转移到仅800像素宽的区域.他可以选择要聚焦在屏幕的哪一部分,但不能全部聚焦.如果您用控件填充所有屏幕,则用户永远不会同时看到它们:他会看到其中的一些,而其他所有的只是周围的杂音.您最好只吸引那些需要一起看的重要事物的注意力,使这些事物适合该领域.
因此,将控件划分为亲和力群集",并为每个群集分配不同的页面.

为了更好地理解我在说什么,请尝试打开一个较长的文章页面,并将浏览器的大小设置为1024像素宽(没有其他高度):您只需轻轻一动即可从上到下阅读文本.
无法将浏览器的宽度设置为1920像素:您甚至必须左右移动头部:阅读该文本看起来就像在观看网球比赛,并且在结束时看不到该行的开头,因此请进行返回"操作到下一行有问题.这就是为什么在栏目"中撰写各种报纸的原因.或者...文本本身不会有这么宽的行,如果宽的浏览器留有一些空白(浪费的)空间,这会使用户调整浏览器的大小并最终打开另一个浏览器.

应用程序和对话框也会发生同样的情况.小心!
What «Superman», said is technically correct, but ... you should consider a better GUI design for your application, because ... it doesn''t fit the usability requiremts.

The first thing I shold ask myself is why is the dialog so wide.
Is it because it has been required as such? If yes, then your application must nor run on screen smaller than the required size: you should state that in the release note, wharning the user that using that app on a smaller device is not supported because ... it has been required to "not support it"!

If no, than you should make no assumption about the size of the device ad assuming that -if the user has a wide device- may be it is not to have wider window but to have many windos on it. Your design should take the minimum space required to the dialog to be profiquely usable.
If there is too much empty space or very wide controls the user will never fill up completely, reduce them.
If there are control that are "poorly related" (in the sense that what they represent is not mutually dependent on others) they can sit on different dialogs, may be represented as pages;of a container tabbed window.

In general consider that a dialog that''s wider to 800x600 (or 1024 x 800 in more extreme cases) is a badly designed dialog. This independently on the width, in pixels, of the screen.

The reason is that the density of a screen is defined to let the screen observed from a fixed distance (usually 50 to 80 centimeter). With the normal resolution of the eyes, this result in a 96dpi density.

The user that has al 1920 or more wider screen, if sitting at 80 cm from it, cannot "focalize" on it entirely: his attention will go to an area that is just 800 pixels wide. He can choose which part of the screen to focalize, but cannot focalize it all. if you fill-up all the screen with controls, the user will never look them all-together simultaneously: he will see some of them, with all the other as just noise around. You had better to capture its attention only to things that are important to be seen together, making those things to fit that area.
So divide your control in "affnity clusters" and give each cluster a different page.

To better feel what I am saying, try opening a long article page, and size your browser to be 1024 pixel wide (no mater how high): you can read the text from top to bottom with just a small movement of the eyes.
Not make your browser 1920 pixel wide: you have to even move your head left to right: reading that text looks like watching a tennis match, and you cannot see the beginning of the line when you are at end, so making the "return" to the next line problematic. that''s the reason why wide newspapers are written in "columns". Or... the text itself will not have so wide lines, and the wide browser if left with some empty (wasted) space, that makes the user to resize the browser and eventually open another one aside.

The same happen with application and dialogs. Take care of it!


您可以使用MoveWindowSetWindowPos API来调整对话框的大小.
但是,您还需要在对话框中的每个控件上使用上述API来移动或调整它们的大小,以便在更改对话框大小时都可以看到它们.

您可以使用HORZRESVERTRES参数使用API​​ GetDeviceCaps获得屏幕分辨率.
您还可以将SystemParametesInfo API与SPI_GETWORKAREA参数一起使用以获得屏幕分辨率.
You can use the MoveWindow or SetWindowPos APIs to adjust the size of your dialog.
But you will also need to use the above APIs on every control in the dialog to move or resize them so that they will all be visible when the size of the dialog is changed.

You can get the resolution of the screen using the API GetDeviceCaps using the HORZRES and VERTRES parameters.
You can also use the SystemParametesInfo API with the SPI_GETWORKAREA parameter to get the screen resolution.


以下是示例代码,您可以根据需要进行修改.您可能还需要添加代码以相应地移动对话框中存在的控件(如果有).

Following is the sample code, which you can modify as per your need. You may also need to add the code to move the controls (if any) present on your dialog accordingly.

HWND hwndOwner = NULL; 
    RECT rc, rcDlg, rcOwner; 

    // Get the owner window and dialog box rectangles. 

    hwndOwner = GetDesktopWindow(); 

    GetWindowRect(hwndOwner, &rcOwner); 
    GetWindowRect(hwndDlg, &rcDlg); 
    CopyRect(&rc, &rcOwner); 

    // Offset the owner and dialog box rectangles so that right and bottom 
    // values represent the width and height, and then offset the owner again 
    // to discard space taken up by the dialog box. 

    OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); 
    OffsetRect(&rc, -rc.left, -rc.top); 
    OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); 

    SetWindowPos(hwndDlg, 
                 HWND_TOP, 
                 rcOwner.left + (rc.right / 2), 
                 rcOwner.top + (rc.bottom / 2), 
                 0, 0,          // Ignores size arguments. 
                 SWP_NOSIZE); 


这篇关于如何将对话框调整为屏幕分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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