I have a fixed window without borders, to which I remove the maximize and minimize buttons, etc., which completely covers the user's screen, but leaves the taskbar visible as follows:
FormBorderStyle = FormBorderStyle.None;
Left = Top = 0;
Width = Screen.PrimaryScreen.WorkingArea.Width;
Height = Screen.PrimaryScreen.WorkingArea.Height;
ShowInTaskbar = true;
but not having the maximize and minimize buttons does not allow you to minimize the window and it feels unnatural to navigate between open programs or search for something on the desktop...
I have tried to replicate the minimize and maximize event by capturing the event with activate as follows:
public void Toggle_Windows(object sender, EventArgs e)
{
if(this.WindowState == FormWindowState.Maximized | this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
ShowInTaskbar = true;
}
else
{
this.WindowState = FormWindowState.Maximized;
}
}
but it does not work correctly since it hides the window and hides the icon in the task bar. I don't get any messages or errors from the code debugger
By default, borderless forms are not designed to be minimized, which means that when the
FormBorderStyle
form property is set tonone
, you will notice that clicking the application box on the taskbar does not minimize the form.This can be fixed by overriding
CreateParams
and adding the styleWS_MINIMIZEBOX
to the window and windowCS_DBLCLKS
class styles.Simply by adding the following code you get the minimized i of the window:
Font:
https://www.fluxbytes.com/csharp/minimize-a-form-without-border-using-the-taskbar/
That happened to me and I solved it in the following way, I made the application to be minimized when I double clicked on the form.
To do this we put this code in the DoubleClick event of the form:
In this way we ask that the mouse button that is pressed is the left one, and by double clicking anywhere on the form it will be minimized