C# 实现WinForm 全屏
2008-05-05 16:26
218 查看
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;namespace WindowsFormsApplication3{ public partial class Form1 : Form { /// <summary> [DllImport("user32.dll")] public static extern int FindWindow( string lpClassName, // class name string lpWindowName // window name ); [DllImport("user32.dll")] public static extern bool SetWindowPos( int hWnd, // handle to window int hWndInsertAfter, // placement-order handle int X, // horizontal position int Y, // vertical position int cx, // width int cy, // height uint uFlags // window-positioning options ); /// <summary> /// 显示和隐藏鼠标指针. /// </summary> [DllImport("user32.dll", EntryPoint = "ShowCursor", CharSet = CharSet.Auto)] public static extern int ShowCursor(int bShow); const int SWP_NOSIZE = 0x1; const int SWP_NOMOVE = 0x2; const int SWP_NOZORDER = 0x4; const int SWP_NOREDRAW = 0x8; const int SWP_NOACTIVATE = 0x10; const int SWP_FRAMECHANGED = 0x20; //The frame changed:send WM_NCCALCSIZE const int SWP_SHOWWINDOW = 0x40; const int SWP_HIDEWINDOW = 0x80; const int SWP_NOCOPYBITS = 0x100; const int SWP_NOOWNERZORDER = 0x200; // Don't do owner Z ordering const int SWP_DRAWFRAME = SWP_FRAMECHANGED; const int SWP_NOREPOSITION = SWP_NOOWNERZORDER; // SetWindowPos() hwndInsertAfter values const int HWND_TOP = 0; const int HWND_BOTTOM = 1; const int HWND_TOPMOST = -1; const int HWND_NOTOPMOST = -2; private int hTaskBar; public Form1() { InitializeComponent(); this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; //this.Size=SystemInformation.PrimaryMonitorSize; this.hTaskBar = FindWindow("Shell_traywnd", null); } private void Form1_Load(object sender, EventArgs e) { SetWindowPos(this.hTaskBar, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDEWINDOW); ShowCursor(0); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { SetWindowPos(this.hTaskBar, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW); } private void Form1_MouseHover(object sender, EventArgs e) { ShowCursor(1); } }}
相关文章推荐
- C# WinForm中 让控件全屏显示的实现代码
- C#实现WinForm窗口全屏显示
- C# 实现Winform全屏后不遮挡任务栏,显示任务栏
- C# WinForm 实现增删改查等功能(Access版) 系列之四-删除
- c#实现按用户角色分配菜单的使用权限(WinForm)
- C#实现WinForm窗口最小化到系统托盘
- 【.Net码农】C#WinForm编程中多语言的实现
- C# winform 实现MD5加密功能
- C#实现Winform间的数据交互的三种方法
- 使用C#实现WINFORM窗体的动画效果
- 如何在C#中实现窗体全屏模式
- c# WinForm窗体实现动态时间展示
- C#的Winform多语言实现(resx文件)
- C#中WinForm实现控件随窗体大小自适应改变
- 转载:winform的DataGridView中用C#实现按钮列置灰
- winform(c#)中实现打印机相关功能
- C#开发 WinForm如何在选项卡中集成加载多个窗体 实现窗体复用(图文)
- 在C#中实现listbox的项添加与移除(winform)
- 使用C#实现WinForm窗体的动画效果