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();
Related
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!
I'm trying to do transparent and clickable form. This form will work full screen. So this form must be clickable. For example if desktop exists behind this form, I must be able to click to folders and open.
If a document exists I must be able to change this document. I couldn't solve how to enable this.
I think it can be done with API codes, but I don't know which API. If you can give me some information/link I will be pleased.
This is simple and works without calling any API function.
But it will prohibit any interaction of your program with the user..
For a Screensaver this makes no sense, however, at least not as you described it.
The rule is this:
Anything that is not 100% transparent is not click-through.
So you could easily create a darker screen using Opacity and a Black BackColor but it won't be click-through.
The simplest solution would be to switch between the both modes upon MouseMove using a Timer to turn the saving mode back on, maybe like this:
public Form1()
{
InitializeComponent();
this.Text = "";
this.MinimizeBox = false;
this.MaximizeBox = false;
this.ControlBox = false;
this.WindowState = FormWindowState.Maximized;
switchSaverState(false);
}
Point lastMosePosition = Point.Empty;
int savingWaitMinutes = 10;
int minute = 60000;
Timer timer1 = new Timer;
void switchSaverState(bool saving)
{
if (saving)
{
this.BackColor = Color.Black;
this.Opacity = 0.8;
}
else
{
this.TransparencyKey = Color.Fuchsia;
this.BackColor = Color.Fuchsia;
this.Opacity = 1;
timer1.Interval = minute * savingWaitMinutes;
timer1.Start();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (timer1.Interval == minute * savingWaitMinutes)
{
timer1.Interval = 100;
switchSaverState(true);
lastMosePosition = Cursor.Position;
}
else
{
if (Cursor.Position != lastMosePosition) { switchSaverState(false); }
}
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
lastMosePosition = Cursor.Position;
switchSaverState(false);
}
But again: This is like a Screensver, meaning that you can't work while it 'saves'! To do that use the controls on your monitor!!
I'm trying to create a custom form in WPF. I set the windowStyle to be None
I added 3 buttons :
Close
Max/Min
Hide
What I'm trying to do is when the user clicks on the second button is ,
if the form in normal state , maximize the form to be as the screen size, else if
the form is on maximize state , set the form to the initial size..
This is what I tried, but nothing happens when I first click on the second button
private bool maximized = false;
private void button2_Click(object sender, RoutedEventArgs e)
{
if (!maximized)
{
this.MaxHeight = SystemParameters.PrimaryScreenHeight;
this.MaxWidth = SystemParameters.PrimaryScreenWidth;
this.WindowState = System.Windows.WindowState.Maximized;
maximized = true;
}
else
{
this.WindowState = System.Windows.WindowState.Normal;
maximized = false;
}
}
Am I need to add Invalidate or something like that?
Ok, I Solved it..
When I created the xaml file.. I added a rectangle so the form body will be the rectangle..
I needed to change the rectangle width and height instead..
private void button2_Click(object sender, RoutedEventArgs e)
{
if (!maximized)
{
this.FormBody.Width = SystemParameters.WorkArea.Width; //rectangle's width
this.FormBody.Height = SystemParameters.WorkArea.Height;// rectangle's height
this.WindowState = System.Windows.WindowState.Maximized;
maximized = true;
}
else
{
this.WindowState = System.Windows.WindowState.Normal;
maximized = false;
}
}
I also change the SystemParameters.PrimaryScreenWidth to be SystemParameters.WorkArea.Width
and also with the Height so in this way the form wont exceed the taskbar
I have this button click event code:
private void button1_Click(object sender, EventArgs e)
{
offlineOnline = false;
init();
backgroundWorker1.RunWorkerAsync();
button1.Enabled = false;
this.Text = "Processing...";
label6.Text = "Processing...";
label6.Visible = true;
button2.Enabled = false;
checkBox1.Enabled = false;
checkBox2.Enabled = false;
numericUpDown1.Enabled = false;
button3.Enabled = true;
button6.Enabled = false;
button4.Enabled = true;
button5.Enabled = false;
listBox1.Enabled = false;
}
I set the listBox1 Enabled to be false. But it dosn't look mice. It looks like the listBox still active but in fact the user can't use it.
What i want is some idea what to do with the listBox while the process is on ? ( When clicking the button1 ).
Quick and dirty: disable it and change the background colour to a murky grey.
A little less dirty, subclass ListBox and set the colour when Enabled changes, possibly based on the current Windows theme.
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;
}
}