回答
这可能是你想要的。它创建一个“最大化”窗口而不隐藏任务栏。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Left = Top = 0;
Width = Screen.PrimaryScreen.WorkingArea.Width;
Height = Screen.PrimaryScreen.WorkingArea.Height;
}
}
如果最大化是不是你要找的(由Greebo的建议),那么你就需要通过检查任务栏的位置和大小来计算自己的窗口大小是什么:
http://winsharp93.wordpress.com/2009/06/29/find-out-size-and-position-of-the-taskbar/
如果您已经设置了WindowState = Maximized;确保你已经设置了FormBorderStyle =除None之外的任何东西。如果您设置为None,它将覆盖您的任务栏。
我不得不回答这个问题here:
有一件事我离开了说明 - 我倒是关闭了最大化按钮。当我测试再次打开该属性时,任务栏再次出现。显然,假设您不希望最大化按钮创建一个自助服务终端式应用程序,您不希望用户看到除应用程序屏幕以外的任何内容。不完全是我所期望的,但我猜想是有效的。
我有这个问题,杰夫的帮助解决了它。首先,将windowstate设置为Maximized。但不要禁用MaximizeBox。然后,如果你想MaximizeBox被禁用,你应该这样做编程:
private void frmMain_Load(object sender, EventArgs e)
{
this.MaximizeBox = false;
}
尝试没有FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
和注释行,如:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Left = Top = 0;
Width = Screen.PrimaryScreen.WorkingArea.Width;
Height = Screen.PrimaryScreen.WorkingArea.Height;
}
}
我做的方式,它是通过这个代码:
this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
this.WindowState = FormWindowState.Maximized;
我认为这应该是被批准的答案,因为上面提供的解决方案不允许正常的Windows状态更改行为。 – mohnston
private void frmGateEntry_Load(object sender, EventArgs e)
{
// set default start position to manual
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
// set position and size to the Form.
this.Bounds = Screen.PrimaryScreen.WorkingArea;
}
如果您有多个屏幕,则必须重置MaximizedBounds的位置:
Rectangle rect = Screen.FromHandle(this.Handle).WorkingArea;
rect.Location = new Point(0, 0);
this.MaximizedBounds = rect;
this.WindowState = FormWindowState.Maximized;
我不擅长解释,但这是我用来最大化或全屏显示不覆盖任务栏的winforms的代码。希望能帮助到你。 ^^
private void Form_Load(object sender, EventArgs e)
{
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
this.Width = Screen.PrimaryScreen.WorkingArea.Width;
this.Location = Screen.PrimaryScreen.WorkingArea.Location;
}
有关此代码专用答案的一些解释可能会有所帮助! – Pyves
- 1. 的Ant jar任务 - 包括包装但不包括子包
- 2. 应用留守任务栏在全屏
- 3. C#全屏幕,隐藏任务栏
- 4. 删除一切,但不包括模式
- 5. 任务栏紧凑模式?
- 6. 当visual studio处于全屏模式时,如何将任务栏“始终置顶”?
- 7. 目前UIViewController在UIViewController模态内不包括全屏
- 8. iphone - 不是全屏模式
- 9. 如何制作一个全屏的窗口,但仍显示任务栏
- 10. File_exists但不包括
- 11. 隐藏Xcode 4.3工具栏不可用于全屏模式
- 12. Gradle'build'任务包括什么
- 13. Twitter Bootstrap模式背景不包括iPad上的整个屏幕
- 14. 强制模式窗体在任务栏
- 15. Flex全屏模式
- 16. MigLayout全屏模式
- 17. WPF全屏模式
- 18. 保存全屏截图包括酒吧
- 19. 正则表达式,但不包括
- 20. awk的排除范围模式,但包括启动模式
- 21. 最大化自定义窗口,包括任务栏
- 22. 在java中使用Selenium截图,包括任务栏
- 23. 如何防止覆盖任务栏的全屏窗体?
- 24. 使WPF应用程序全屏幕(封面任务栏)可靠
- 25. 全屏闪烁任务栏Windows Mobile 6应用程序
- 26. 如何防止任务栏出现WPF非全屏窗口?
- 27. 闪光舞台全屏模式,动画片段全屏模式?
- 28. 全屏模式在Adobe AIR应用程序,但没有窗口或标题栏
- 29. 参数化的安全任务包括 - '参数未定义'
- 30. 正则表达式,不包括超模
这是全屏的定义。也许你想将其设置为“最大化”而不是? –
@Evil:你应该回答你的问题。 – Sung
@TheE:我将它设置为this.windowstate =最大化... – user698065