2011-06-20 22 views
3

我有一个WinForms应用程序,它在我登录时设置为全屏模式。全屏模式,但不包括任务栏

我的问题是它也覆盖了Windows任务栏。我不希望我的应用程序覆盖任务栏。

这怎么办?

+4

这是全屏的定义。也许你想将其设置为“最大化”而不是? –

+0

@Evil:你应该回答你的问题。 – Sung

+1

@TheE:我将它设置为this.windowstate =最大化... – user698065

回答

11

这可能是你想要的。它创建一个“最大化”窗口而不隐藏任务栏。

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; 
    } 
} 
0

如果您已经设置了WindowState = Maximized;确保你已经设置了FormBorderStyle =除None之外的任何东西。如果您设置为None,它将覆盖您的任务栏。

3

我不得不回答这个问题here

有一件事我离开了说明 - 我倒是关闭了最大化按钮。当我测试再次打开该属性时,任务栏再次出现。显然,假设您不希望最大化按钮创建一个自助服务终端式应用程序,您不希望用户看到除应用程序屏幕以外的任何内容。不完全是我所期望的,但我猜想是有效的。

我有这个问题,杰夫的帮助解决了它。首先,将windowstate设置为Maximized。但不要禁用MaximizeBox。然后,如果你想MaximizeBox被禁用,你应该这样做编程:

private void frmMain_Load(object sender, EventArgs e) 
{ 
    this.MaximizeBox = false; 
} 
0

尝试没有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; 
    } 
} 
9

我做的方式,它是通过这个代码:

this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea; 
this.WindowState = FormWindowState.Maximized; 
+1

我认为这应该是被批准的答案,因为上面提供的解决方案不允许正常的Windows状态更改行为。 – mohnston

0
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; 
    } 
1

如果您有多个屏幕,则必须重置MaximizedBounds的位置:

Rectangle rect = Screen.FromHandle(this.Handle).WorkingArea; 
rect.Location = new Point(0, 0); 
this.MaximizedBounds = rect; 
this.WindowState = FormWindowState.Maximized; 
0

我不擅长解释,但这是我用来最大化或全屏显示不覆盖任务栏的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; 

    } 
+1

有关此代码专用答案的一些解释可能会有所帮助! – Pyves