Completely Maximized C# WinForm - c#

Is there a way to make the C# form completely covers the whole screen? I would be doing this without explorer.exe running, if that makes it easier. I don't want it to be full screen, because I want other programs to be able to run above it. Thanks!

private void frm_Load(object sender, EventArgs e)
{
ControlBox = false;
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
}
private void frm_KeyDown(object sender, KeyEventArgs e)
{
// restore form on Escape key press.
if (e.KeyCode == Keys.Escape)
{
ControlBox = true;
FormBorderStyle = FormBorderStyle.Sizable;
WindowState = FormWindowState.Normal;
}
}

Related

c# Why can I not return my application from minimize?

I have googled this and all the sites I have seen tell me the same thing for minimizing my app and then returning it to normal. I can minimize it fine but when I click on the icon in the tray then nothing happens. Here is my code.
private void Form1_SizeChanged(object sender, EventArgs e)
{
bool PointerNotOnTaskbar = Screen.GetWorkingArea(this).Contains(Cursor.Position);
if (this.WindowState == FormWindowState.Minimized && PointerNotOnTaskbar)
{
notifyIcon1.Icon = SystemIcons.Application;
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.ShowInTaskbar = true;
WindowState = FormWindowState.Normal;
notifyIcon1.Visible = false;
}
I have also tried
this.WindowState = FormWindowState.Normal;
Comment out this: this.ShowInTaskbar = false;
If the form is minimized and not visible in taskbar will take a spell to bring it back!

Make form invisible

I know this question seems very simple but its not working for me, i think i changed a property by accident so the form wont go invisible.
on load, i have :
this.Visible = false;
this.ShowInTaskbar = false;
this.ShowIcon = false;
it doesnt show in taskbar or the icon but for some reason its still visible like in the image below
i know thats the form because i changed the color to red and it turned red
This is what you can do:
private void Form1_Load(object sender, EventArgs e)
{
this.Opacity = 0; //Add this line.
this.Visible = false;
this.ShowInTaskbar = false;
this.ShowIcon = false;
}
If you're trying to hide the form, you can use :
this.Hide();

How to make Application ontop of all windows and allow message box to be shown correctly

I am writing an application, that on specific conditions must make my application ontop of all other windows applications.
I do this in timer code as shown below that runs every 10 ms. That is fine. However if i need to throw a message box if there is an error then the messagebox ok button cannot be pressed because the form is made topmost every 10 ms - The button can be seen but you cant click ok.
Assumably because the first time you click the button brings the errorbox modal and by the time you click the ok button 10 ms has passed and the form is now ontop again.
How can i fix this issue ?
Timer
private void timer1_Tick(object sender, EventArgs e)
{
this.Visible = true;
this.TopMost = true;
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
}
Show an Error
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Some error occured");
}
private void timer1_Tick(object sender, EventArgs e)
{
if (!this.TopMost == true)
this.TopMost = true;
this.Visible = true;
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Some error occured");
}

How to minimize and maximize in C#.Net?

I want to minimize and maximize manually in C#.net.
I changed form's BorderStyle into none.
So there are no maximize,minimize and close button from bar.
I want to manually create with button like those functions.
I want to do three functions in button click events.
You have to set the forms WindowState property something like this:
In Windows Forms:
private void button1_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
In WPF:
private void button1_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
Form.WindowState Property
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.windowstate%28v=VS.90%29.aspx
public FormWindowState WindowState { get; set; }
For example -
var form = new Form();
form.WindowState = FormWindowState.Maximized;
form.WindowState = FormWindowState.Minimized;
form.WindowState = FormWindowState.Normal;
However, if you are in the code behind on the main form (or any form) just do this -
WindowState = FormWindowState.Maximized;
If you're using WindowsForms you have to change the WindowState property :)
private void button4_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}

c# how to FormWindowState.Normal

i have this code:
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
about About = new about();
About.ShowDialog();
}
it minimizes the parent window state to minimized and displays a splash form.
my question is when the splash screen closes how do i get back to parentwindowstate.normal?
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
about About = new about();
About.ShowDialog();
this.WindowState = FormWindowState.Normal;
}
If you're using ShowDialog instead of Show; you can add
this.WindowState = FormWindowState.Normal;
after the ShowDialog call. (ShowDialog is blocking, unlike Show.)
Call ShowDialog() like this:
About.ShowDialog(this);
Then, in the About form's FormClosing event, put:
this.Parent.WindowState = WindowState.Normal;

Categories