首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

麻烦大家发上C#让winform全屏运行的代码

2012-08-13 
麻烦大家发下C#让winform全屏运行的代码百度了,看到有说调用API的,还有设置form.size的。对于API这个我不怎

麻烦大家发下C#让winform全屏运行的代码
百度了,看到有说调用API的,还有设置form.size的。对于API这个我不怎么懂,有高手发下带注释的代码吗?

[解决办法]

C# code
using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;namespace GlobalTechnologyInc.SnmpProject.CustomClass{    /// <summary>    /// Selected Win AI Function Calls    /// </summary>    class WindowsFullScreenApi    {        [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]        public static extern int GetSystemMetrics(int which);        [DllImport("user32.dll")]        public static extern void            SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,                         int X, int Y, int width, int height, uint flags);        private const int SM_CXSCREEN = 0;        private const int SM_CYSCREEN = 1;        private static IntPtr HWND_TOP = IntPtr.Zero;        private const int SWP_SHOWWINDOW = 64; // 0x0040        public static int ScreenX        {            get { return GetSystemMetrics(SM_CXSCREEN); }        }        public static int ScreenY        {            get { return GetSystemMetrics(SM_CYSCREEN); }        }        public static void SetWinFullScreen(IntPtr hwnd)        {            SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);        }    }} 

热点排行