C# 实现 自动隐藏任务栏 的类似功能

十一路 2008-12-13 11:21:04
我想在程序里面实现 把任务栏隐藏,并且窗体充满整个屏幕

[DllImport("user32.dll")]
internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
internal static extern int ShowWindow(IntPtr hWin, int nCmdShow);

这两个函数 实现了隐藏,但是窗体不能充满屏幕

求教 谢谢
...全文
437 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
猿敲月下码 2008-12-14
  • 打赏
  • 举报
回复
把窗体的Topmost属性改为true
yefeng835 2008-12-14
  • 打赏
  • 举报
回复
帮顶下。。。
  • 打赏
  • 举报
回复
学习了
zhaigates 2008-12-14
  • 打赏
  • 举报
回复
慢慢学习学习
zhaigates 2008-12-14
  • 打赏
  • 举报
回复
慢慢学习
biwei_cn 2008-12-14
  • 打赏
  • 举报
回复

碰到问题了,不懂!

有一个DataGrid 控件,总共有6列,第6列是模板列,且模板列里面放了一个LinkButton控件,ID是 LinkButton1,
我想访问他,并操作他.我在 ItemDataBound事件中,我写成下面的形式,

LinkButton lbt2 = (LinkButton)e.Item.Cells[5].FindControl("LinkButton1");
if (lbt2 != null)
{
lbt2.Text = "hello!";
lbt2.Attributes.Add("onclick", "return confirm('kkek1')");
}

执行结果和预期的一样, LinkButton1 的 text 显示成了 "hello!",且在点击时有这个弹出提示;
但是有一个问题是:在以上代码的 Cells[n]里面,n除了填5 以外, Cells[0]到 Cells[4]都能执行下在的语句,
按理说只能是 第6列,就就是索引为5的才能执行下面的语句,现在出现了这样的情况,是怎么回事呢?

难道是我对e.item.Cells[] 的理解有误吗?
我的理解是:cell[]代表列或单元格的索引,控件是在第6列,就应该是 cells[5]
zoOoz 2008-12-14
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

//这是你需要的代码
this.FormBorderStyle = FormBorderStyle.None;
this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Maximized;

//这是随便写写的代码
Label lb = new Label();
lb.Text = "这是你需要的效果,请按Alt+F4关闭";
lb.TextAlign = ContentAlignment.MiddleCenter;
lb.Dock = DockStyle.Fill;
this.Controls.Add(lb);
}
}
}
GTX280 2008-12-14
  • 打赏
  • 举报
回复
实现全屏效果:

//写在InitializeComponent();之后
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
net5i 2008-12-13
  • 打赏
  • 举报
回复
怎么代码缩进也没了,重新贴一下

设置窗口的大小为屏幕即可:

//这个函数是用来获取屏幕的显示区域的,包括多显示器的
private Rectangle GetAllScreenBounds()
{
Rectangle rect = new Rectangle(0, 0, 0, 0);
foreach (Screen screen in Screen.AllScreens)
{
Rectangle rectScreen = screen.Bounds;
if (rectScreen.Left < rect.Left)
{
rect.Width += (rect.Left - rectScreen.Left);
rect.X = rectScreen.X;
}
if (rectScreen.Right > rect.Right)
rect.Width += (rectScreen.Right - rect.Right);
if (rectScreen.Top < rect.Top)
{
rect.Height += (rect.Top - rectScreen.Top);
rect.Y = rectScreen.Y;
}
if (rectScreen.Bottom > rect.Bottom)
rect.Height += (rectScreen.Bottom - rect.Bottom);
}
return rect;
}

//然后在某个地方将这个屏幕区域设置给窗口:
this.Bounds = this.GetAllScreenBounds();

注意:这个代码仅仅是设置全屏的,隐藏任务栏还是用你原来的代码
net5i 2008-12-13
  • 打赏
  • 举报
回复
设置窗口的大小为屏幕即可:

//这个函数是用来获取屏幕的显示区域的,包括多显示器的
private Rectangle GetAllScreenBounds()
{
Rectangle rect = new Rectangle(0, 0, 0, 0);
foreach (Screen screen in Screen.AllScreens)
{
Rectangle rectScreen = screen.Bounds;
if (rectScreen.Left < rect.Left)
{
rect.Width += (rect.Left - rectScreen.Left);
rect.X = rectScreen.X;
}
if (rectScreen.Right > rect.Right)
rect.Width += (rectScreen.Right - rect.Right);
if (rectScreen.Top < rect.Top)
{
rect.Height += (rect.Top - rectScreen.Top);
rect.Y = rectScreen.Y;
}
if (rectScreen.Bottom > rect.Bottom)
rect.Height += (rectScreen.Bottom - rect.Bottom);
}
return rect;
}

//然后这个屏幕区域设置给窗口:
this.Bounds = this.GetAllScreenBounds();
grearo 2008-12-13
  • 打赏
  • 举报
回复
窗体的StartPosition设置为CenterScreen
不要最大化,直接调整窗体的大小

111,130

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧