0
votes

I have a C#.2017 project, Home form is none border (set in properties). It always start with maximize and startposition is windowsdefaultlocation/manual (I tried). I try many code but it still runs and hide taskbar.

I want to run the form in none border, maximize/full screen mode, the form doesn't hide the taskbar of windows 10.

Tried this links:

https://social.msdn.microsoft.com/Forums/windows/en-US/e81dc341-720e-474a-9c37-75eac3a130cb/howto-show-window-form-on-top-of-taskbar-in-every-resolution?forum=winforms

https://www.c-sharpcorner.com/UploadFile/shubham0987/display-app-in-full-screen-with-windows-taskbar/

How to display a Windows Form in full screen on top of the taskbar?

private void Form1_Load(object sender, EventArgs e)
{
    this.Height = Screen.PrimaryScreen.WorkingArea.Height;
    this.Width = Screen.PrimaryScreen.WorkingArea.Width;
    this.Location = Screen.PrimaryScreen.WorkingArea.Location;

    //Screen currentScreen = Screen.FromHandle(this.Handle);
    //this.Size = new System.Drawing.Size(currentScreen.Bounds.Width, currentScreen.Bounds.Height);
}

It doesn't help me anything. If you have some solution better help me please.

Much thank to all.

2

2 Answers

0
votes

Setting a Forms WindowState to Maximized when your BorderStyle is none will always lay over the taskbar. This is a typical behaviour of a "Fullscreen" application.

However you are on the right track. If you want to have a semi-fullscreen experience without laying over the taskbar you have to set the Location and Size of your Form manually.

Important here is that you not only set these values manually but also take away control from the OS itself as it will always try to position a Form by some ruleset.

private void Form1_Load(object sender, EventArgs e)
{
  //Hiding the Border to simulate a fullscreen-experience
  this.FormBorderStyle = FormBorderStyle.None;
  //Telling the operating system that we want to set the start position manually
  this.StartPosition = FormStartPosition.Manual;

  //Actually setting our Width, Height, and Location
  this.Height = Screen.PrimaryScreen.WorkingArea.Height;
  this.Width = Screen.PrimaryScreen.WorkingArea.Width;
  this.Location = Screen.PrimaryScreen.WorkingArea.Location;
}

Just a little side node: You might want to think about people with multiple screens and on which screen your application should appear (maybe let the user decide by some setting etc).

0
votes

Maybe this one is quite similar to something I need:

this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size ;