简体   繁体   中英

How to maximize application in over the Taskbar at Windows Forms?

I need to maximize my application in C# that it will be over the taskbar. I have change the property WindowState = Maximized. But the lower part of the application appears under the taskbar. I want the status bar to appear above with the taskbar also shown below it.

在此输入图像描述

It's maximized but where is my statusbar :)

在此输入图像描述

This is Normal State of Window; you can see status bar in this pic.

As I indicated in my comment, you've done something odd to your window, which is why you're getting this behaviour. I can reproduce this. I created a new WinForms project, put a button on the form that has this code:

private void button1_Click(object sender, EventArgs e)
{
    this.WindowState = FormWindowState.Maximized;
}

Added a status bar, and set the MaximizeBox property of the form to false . Running the code, pressing my custom button, the form maximizes, but the status bar disappears behind the task bar.

If I then close the form, re-enable the MaximizeBox property, and re-run the project, then maximizing the form gets the behaviour you want (the status bar's bottom is aligned with the top of the task bar). So re-enable your MaximizeBox and you should be done.

(Once the Maximize box is available, maximizing works whether using that or the custom button)

First, make sure that you have no ControlBox, but text in the Form Text - this adds the title bar. Then, set your form WindowState to Maximized .

The last thing you do in the Form_Load event is to set the form Text property to an empty string. The Title bar is removed, the form is maximized, and the Task Bar is visible.

I am guessing that you have TopMost property set to 'True'. If you need this setting then you can get taskbar information from a Win32 API call. There is some information about it here:

Taskbar Height

Otherwise you could just disable the TopMost setting. You may want to check that your program runs in 64bit os (if you are not already using this). I use VirtualBox with a 64 bit guest o/s for testing 64bit on my 32 bit host. (Requires a 64 bit processor though.)

I hope that this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM