Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Hide form at startup

Hide form at startup

Scheduled Pinned Locked Moved C#
helpquestion
12 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S sopho24

    Can be accessed to visible property from properties window in design view

    Mike HankeyM Offline
    Mike HankeyM Offline
    Mike Hankey
    wrote on last edited by
    #3

    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

    S 1 Reply Last reply
    0
    • Mike HankeyM Mike Hankey

      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

      S Offline
      S Offline
      sopho24
      wrote on last edited by
      #4

      Any code remain in designer.cs; for example a visible property with true value?

      Mike HankeyM 1 Reply Last reply
      0
      • Mike HankeyM Mike Hankey

        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

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #5

        In your form's constructor write this line

        this.Visible = false;

        Regards:rose:

        Mike HankeyM 1 Reply Last reply
        0
        • S sopho24

          Any code remain in designer.cs; for example a visible property with true value?

          Mike HankeyM Offline
          Mike HankeyM Offline
          Mike Hankey
          wrote on last edited by
          #6

          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

          1 Reply Last reply
          0
          • N Nader Elshehabi

            In your form's constructor write this line

            this.Visible = false;

            Regards:rose:

            Mike HankeyM Offline
            Mike HankeyM Offline
            Mike Hankey
            wrote on last edited by
            #7

            Tried that no good!

            N 1 Reply Last reply
            0
            • Mike HankeyM Mike Hankey

              Tried that no good!

              N Offline
              N Offline
              Nader Elshehabi
              wrote on last edited by
              #8

              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:

              Mike HankeyM 1 Reply Last reply
              0
              • N Nader Elshehabi

                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:

                Mike HankeyM Offline
                Mike HankeyM Offline
                Mike Hankey
                wrote on last edited by
                #9

                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

                N 1 Reply Last reply
                0
                • Mike HankeyM Mike Hankey

                  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

                  D Offline
                  D Offline
                  dsl fahk
                  wrote on last edited by
                  #10

                  Have you tried making the opacity of the form 0? and then when the system tray is clicked the opacity is 100? And then you could make it slowly fade in for a cool effect.

                  1 Reply Last reply
                  0
                  • Mike HankeyM Mike Hankey

                    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

                    N Offline
                    N Offline
                    Nader Elshehabi
                    wrote on last edited by
                    #11

                    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:

                    Mike HankeyM 1 Reply Last reply
                    0
                    • N Nader Elshehabi

                      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:

                      Mike HankeyM Offline
                      Mike HankeyM Offline
                      Mike Hankey
                      wrote on last edited by
                      #12

                      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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups