• 大小: 46.16 KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-09-19
  • 语言: C#
  • 标签: piexl  

资源简介

通过获取显示器的分辨率,自动调整Form中控件的布局

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Collections;
using Resolution;

namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        Resolution.Resolution r = new Resolution.Resolution();
        Resolution.Resolution.DEVMODE dm = new Resolution.Resolution.DEVMODE();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            dm = r.getResolution();
            textBox1.Text = textBox4.Text = dm.dmPelsWidth.ToString();
            textBox2.Text = textBox5.Text = dm.dmPelsHeight.ToString();
            textBox3.Text = textBox6.Text = dm.dmDisplayFrequency.ToString();
            textBox7.Text = textBox8.Text = dm.dmBitsPerPel.ToString();
            this.ClientSize = new Size(dm.dmPelsWidth dm.dmPelsHeight);
            this.Location = new Point(0 0);
        }

        private void Form1_FormClosed(object sender FormClosedEventArgs e)
        {
            r.setResolution(int.Parse(textBox1.Text) int.Parse(textBox2.Text) int.Parse(textBox3.Text));
        }

        private void button1_Click(object sender EventArgs e)
        {
            List allMode = new List();
            allMode = r.getAllResolution();
            foreach (Resolution.Resolution.DEVMODE dm in allMode)
            {
                string sitem = dm.dmPelsWidth + “ד + dm.dmPelsHeight + ““ + dm.dmDisplayFrequency + “Hz“ + dm.dmBitsPerPel + “位“;
                listBox1.Items.Add(sitem);
            }
        }

        private void listBox1_MouseDoubleClick(object sender MouseEventArgs e)
        {
            //下面主要是从列表的文本上分拆出宽、高、频率、位数,主要是匹配列表添加时的格式
            string[] sitem = listBox1.Text.Split(‘‘);
            string[] widthANDheight = sitem[0].Split(‘ב);
            int iWidth = int.Parse(widthANDheight[0]);
            int iHeight = int.Parse(widthANDheight[1]);
            int iFrequery = int.Parse(sitem[1].Remove(sitem[1].Length - 2 2));

            int iBits = int.Parse(sitem[2].Remove(sitem[2].Length - 1 1));

            r.setResolution(iWidth iHeight iFrequery iBits);
            dm = r.getResolution();
            textBox4.Text = dm.dmPelsWidth.ToString();
            textBox5.Text = dm.dmPelsHeight.ToString();
            textBox6.Text = dm.dmDisplayFrequency.ToString();
            textBox8.Text = dm.dmBitsPerPel.ToString();
        }

    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5612  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Properties\Resources.resx

     文件        249  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Properties\Settings.settings

     文件       1190  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Properties\AssemblyInfo.cs

     文件       2892  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Properties\Resources.Designer.cs

     文件       1102  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Properties\Settings.Designer.cs

     文件       5814  2008-08-24 02:26  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Form1.resx

     文件       3300  2008-08-23 23:05  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\WindowsApplication2.csproj

     文件       5632  2005-12-08 14:51  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\bin\Debug\WindowsApplication2.vshost.exe

     文件      28672  2009-04-20 10:16  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\bin\Debug\WindowsApplication2.exe

     文件      38400  2009-04-20 10:16  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\bin\Debug\WindowsApplication2.pdb

     文件        180  2008-08-24 02:26  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.Form1.resources

     文件        180  2008-08-23 17:26  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.Properties.Resources.resources

     文件      28672  2009-04-20 10:16  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.exe

     文件        842  2008-08-24 02:26  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.csproj.GenerateResource.Cache

     文件      38400  2009-04-20 10:16  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.pdb

     文件        352  2009-04-20 10:16  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\WindowsApplication2.csproj.FileList.txt

     文件      12300  2008-08-24 02:26  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Form1.Designer.cs

     文件       5486  2008-08-24 03:00  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Resolution.cs

     文件        478  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Program.cs

     文件       2764  2009-04-20 10:16  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Form1.cs

     文件        946  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2.sln

    ..A..H.     18432  2009-04-20 10:43  获取显示器的分辨率\WindowsApplication2\WindowsApplication2.suo

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug\TempPE

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\bin\Debug

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj\Debug

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\Properties

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\bin

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2\obj

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2\WindowsApplication2

     目录          0  2008-08-23 17:25  获取显示器的分辨率\WindowsApplication2

............此处省略4个文件信息

评论

共有 条评论

相关资源