| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 816 人关注过本帖
标题:[讨论]C#-API-改变分辨率
只看楼主 加入收藏
houyunqing
Rank: 1
等 级:新手上路
帖 子:476
专家分:0
注 册:2005-4-1
收藏
 问题点数:0 回复次数:3 
[讨论]C#-API-改变分辨率

C#的设计者们真是可恨,弄了些不错的接口就发懒了,也不扩充扩充C#自己的库!!什么事情都要调API,这里给大家介绍一下用API改变分辨率的东东(要改变的时候调用SetSize(int x,int y);) using System; using System.Runtime.InteropServices;

public class ScreenSet { public enum DMDO { DEFAULT = 0, D90 = 1, D180 = 2, D270 = 3 }

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] struct DEVMODE { public const int DM_DISPLAYFREQUENCY = 0x400000; public const int DM_PELSWIDTH = 0x80000; public const int DM_PELSHEIGHT = 0x100000; private const int CCHDEVICENAME = 32; private const int CCHFORMNAME = 32;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst=CCHDEVICENAME)] public string dmDeviceName; public short dmSpecVersion; public short dmDriverVersion; public short dmSize; public short dmDriverExtra; public int dmFields;

public int dmPositionX; public int dmPositionY; public DMDO dmDisplayOrientation; public int dmDisplayFixedOutput;

public short dmColor; public short dmDuplex; public short dmYResolution; public short dmTTOption; public short dmCollate; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=CCHFORMNAME)] public string dmFormName; public short dmLogPixels; public int dmBitsPerPel; public int dmPelsWidth; public int dmPelsHeight; public int dmDisplayFlags; public int dmDisplayFrequency; public int dmICMMethod; public int dmICMIntent; public int dmMediaType; public int dmDitherType; public int dmReserved1; public int dmReserved2; public int dmPanningWidth; public int dmPanningHeight; }

[DllImport("user32.dll", CharSet=CharSet.Auto)] //static extern int ChangeDisplaySettings( DEVMODE lpDevMode, int dwFlags);

static extern int ChangeDisplaySettings( [In] ref DEVMODE lpDevMode, int dwFlags); private System.ComponentModel.Container components = null; public static void SetSize(int x,int y) { Form1 t = new Form1(); long RetVal=0; DEVMODE dm = new DEVMODE(); dm.dmSize= (short)Marshal.SizeOf(typeof(DEVMODE)); dm.dmPelsWidth = x; dm.dmPelsHeight= y; dm.dmDisplayFrequency=85; dm.dmFields = DEVMODE.DM_PELSWIDTH | DEVMODE.DM_PELSHEIGHT | DEVMODE.DM_DISPLAYFREQUENCY; RetVal = ChangeDisplaySettings(ref dm, 0); } }

搜索更多相关主题的帖子: API 分辨率 
2005-05-04 20:53
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
我同意你的看法。
2005-05-04 21:22
fuyu888
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2005-4-14
收藏
得分:0 
非托管的字段我看到头痛啊~~~

------此人由于过于英俊,头像正面被系统永远封印----
2005-05-05 10:15
wangybo
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2005-8-15
收藏
得分:0 
能不能详细的介绍一下,这样讲太笼统了一点吧。
2005-08-18 16:23
快速回复:[讨论]C#-API-改变分辨率
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043025 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved