在系统分辨率在运行时更改时如何更改表单大小 [英] How to change the form size while the system resolution change at runtime

查看:89
本文介绍了在系统分辨率在运行时更改时如何更改表单大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在开发Windows应用程序,因为我想更改应用程序的大小,并且所有形式都取决于运行时的系统分辨率.所以请帮忙
谢谢.

解决方案

您可以根据系统资源设置加载时的表单大小.
假设您要创建一个尺寸为300 X 300的表格,分辨率为1024 X 768,这意味着您的表格宽度的比例为(300/1024)
表格高度为(300/768)的比例. IE.;您必须通过(300/1024)* Resolution.Width,(300/768)* Resolution.Height计算宽度和高度.

通过以下代码获取当前分辨率

  int  sHeight = Screen.PrimaryScreen.Bounds.Height;
  int  sWidth = Screen.PrimaryScreen.Bounds.Width; 



现在您可以通过
计算表单大小

Width = (yourDesiredFormWidth/YourCurrentScrResolutionWidth) * sWidth;
Height = (yourDesiredFormHeight/YourCurrentScrResolutionHeight) * sHeight;



这里YourCurrentScrResolutionWidth和YourCurrentScrResolutionHeight是常量,即1024和768(如果当前分辨率为1024 X 768). pblm


您好,plz并没有访问太多网站.您可以按照以下步骤轻松进行操作.
使表单窗口状态最大化.
从工具菜单创建表格流.
放在空白表格中.
使表中的单元格流动.
将您的控件放入该单元格.
仅将那些控件停靠到要调整大小的单元格中.
如果您想将所有控件的锚定属性设置在该位置的中心,则不设置任何锚定属性.
如果您想将它们设置为左侧或右侧尺寸,则根据需要设置.
通过表座属性将表停靠到表单中.
如果您想设置某种适当的格式,则可以将组框表单控件组合在一起.
将组框的锚设置为无以使其居中.
如果您难以安排单元格,则可以在单元格中放置更多桌子.
您可以轻松地尝试一下.
保持微笑总是n击中n尝试.
我做到了.
谢谢.


Hi everybody,
I am developing a windows application, in that i want to change the size of the application and all forms depends on the system resolution at runtime.Is der any way to solve this. so pls help me
Thanking you.

解决方案

You can set the form size on load according to the system resoulution.
Suppose you are creating a Form of size 300 X 300 in 1024 X 768 resolution, that means your form width is in the ratio of (300/1024)
and form height is in the ratio of (300/768). i.e.; you have to calculate the width and height by (300/1024) * Resolution.Width , (300/768) * Resolution.Height.

Getting the current resolution by the following code

int sHeight = Screen.PrimaryScreen.Bounds.Height;
 int sWidth = Screen.PrimaryScreen.Bounds.Width;



Now you can calculate the form size by

Width = (yourDesiredFormWidth/YourCurrentScrResolutionWidth) * sWidth;
Height = (yourDesiredFormHeight/YourCurrentScrResolutionHeight) * sHeight;



Here YourCurrentScrResolutionWidth and YourCurrentScrResolutionHeight are the constatnts i.e.;1024 and 768 if your current resolution is 1024 X 768.


Thank u for ur reply, i wil try this dis and contact u if i face any pblm


hi plz dont visit much site for it. u can do it easily by following following steps.
make form windows state maximized.
make a table flow from tool menu.
put it in a blank form.
make cells in the table flow.
put ur controls into that cells.
dock only those controls into the cell whose size u wanna resize.
set anchor properties of all controls none if u wanna set them at center at that position.
if u wanna set them at left or right size then set as u required.
dock table into form through dock property.
if u wanna set some proper format then make group box form controls u wanna put together.
set anchor of group box to none to make it at center.
if u having difficulty in cell arrangement then u can put more table into a cell.
u can do it easily just try it.
keep smile always n hit n try.
i did it by it.
thanks.


这篇关于在系统分辨率在运行时更改时如何更改表单大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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