Hide form at startup
-
I have an that on startup I want the main form to be hidden and activated from System Tray on Click. It works but the main form is always visible on startup???? Any help appreciated Mike
-
Form properties does not contain a visible property but I tried all the basic stuff Hide(), visible = false in the _Load event but for some reason doesn't work. Even tried creating ApplicationContext.MainForm.visible = false in Main()??? private void Form1_Load(object sender, System.EventArgs e) { Rectangle rct = Screen.PrimaryScreen.WorkingArea; Point pt = new Point(rct.Width - this.Width, 0); this.Location = pt; notifyIcon1.Visible = true; this.Hide(); } private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { notifyIcon1.Visible = false; } private static bool isVisible = false; private void notifyIcon1_Click(object sender, System.EventArgs e) { if (isVisible) { this.Visible = false; isVisible = false; } else { this.Visible = true; isVisible = true; } } Thanks
-
Form properties does not contain a visible property but I tried all the basic stuff Hide(), visible = false in the _Load event but for some reason doesn't work. Even tried creating ApplicationContext.MainForm.visible = false in Main()??? private void Form1_Load(object sender, System.EventArgs e) { Rectangle rct = Screen.PrimaryScreen.WorkingArea; Point pt = new Point(rct.Width - this.Width, 0); this.Location = pt; notifyIcon1.Visible = true; this.Hide(); } private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { notifyIcon1.Visible = false; } private static bool isVisible = false; private void notifyIcon1_Click(object sender, System.EventArgs e) { if (isVisible) { this.Visible = false; isVisible = false; } else { this.Visible = true; isVisible = true; } } Thanks
-
I have an that on startup I want the main form to be hidden and activated from System Tray on Click. It works but the main form is always visible on startup???? Any help appreciated Mike
In your form's constructor write this line
this.Visible = false;
Regards:rose:
-
NO here is the InitializeComponent properties for Form1 // // Form1 // this.AutoScale = false; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(162, 511); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Contact Manager"; this.TopMost = true; this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing); this.Load += new System.EventHandler(this.Form1_Load); ??? Mike
-
In your form's constructor write this line
this.Visible = false;
Regards:rose:
Tried that no good!
-
Tried that no good!
Fine. Put the same line of code in the
Form.Shown
event handler. You have to handle the event first of course, and it's present only in DotNet 2.0. If you use older versions you can use the Paint method instead and make a flag whether you want to hide or not.Regards:rose:
-
Fine. Put the same line of code in the
Form.Shown
event handler. You have to handle the event first of course, and it's present only in DotNet 2.0. If you use older versions you can use the Paint method instead and make a flag whether you want to hide or not.Regards:rose:
That worked but the form came up then went invisible? Any insight into how I can keep it from coming up in 1st place? Thanks all for your help Mike
-
I have an that on startup I want the main form to be hidden and activated from System Tray on Click. It works but the main form is always visible on startup???? Any help appreciated Mike
-
That worked but the form came up then went invisible? Any insight into how I can keep it from coming up in 1st place? Thanks all for your help Mike
Alright. I got a much better idea. Simply in the designer or in the constructor set the Form's Opacity to 0 (Zero). This way it will never show up.
Regards:rose:
-
Alright. I got a much better idea. Simply in the designer or in the constructor set the Form's Opacity to 0 (Zero). This way it will never show up.
Regards:rose:
I had thought of that but seemed kludgy. But looks like that may be the only answer! Thank you all for your input and help. I hope I can return the info in the future. Regards Mike