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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Hidden MainForm at startup

Hidden MainForm at startup

Scheduled Pinned Locked Moved C#
question
7 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.
  • A Offline
    A Offline
    andreas_farnstrand
    wrote on last edited by
    #1

    Hi, I can't seem to hide my MainForm at my application startup. I just want the notifyicon in the systray to be visible. mainform.Hide() dosn't work. It displays the mainform anyway. Does somebody now a way to do this? Andreas Färnstrand

    A 1 Reply Last reply
    0
    • A andreas_farnstrand

      Hi, I can't seem to hide my MainForm at my application startup. I just want the notifyicon in the systray to be visible. mainform.Hide() dosn't work. It displays the mainform anyway. Does somebody now a way to do this? Andreas Färnstrand

      A Offline
      A Offline
      Alex Korchemniy
      wrote on last edited by
      #2

      This could work for you: - set ShowInTaskbar to false - set WindowState to FormWindowState.Minimized

      M 1 Reply Last reply
      0
      • A Alex Korchemniy

        This could work for you: - set ShowInTaskbar to false - set WindowState to FormWindowState.Minimized

        M Offline
        M Offline
        Matt Gerrans
        wrote on last edited by
        #3

        And/or set Opacity to 0. These all seem like kludges, though. It seems like there should be a way to tweak the create params. Matt Gerrans

        A 1 Reply Last reply
        0
        • M Matt Gerrans

          And/or set Opacity to 0. These all seem like kludges, though. It seems like there should be a way to tweak the create params. Matt Gerrans

          A Offline
          A Offline
          Alex Korchemniy
          wrote on last edited by
          #4

          Setting Opacity to 0 is X| My two line suggestion should be the easiest possible way of doing it. You can override the CreateParams property like this:

          protected override CreateParams CreateParams
          {
          get
          {
          CreateParams cp = base.CreateParams;
          // change
          return cp;
          }
          }

          I never actually overriden this property before. You can give it a try. This posting is provided "AS IS" with no warranties, and confers no rights. Alex Korchemniy

          M 1 Reply Last reply
          0
          • A Alex Korchemniy

            Setting Opacity to 0 is X| My two line suggestion should be the easiest possible way of doing it. You can override the CreateParams property like this:

            protected override CreateParams CreateParams
            {
            get
            {
            CreateParams cp = base.CreateParams;
            // change
            return cp;
            }
            }

            I never actually overriden this property before. You can give it a try. This posting is provided "AS IS" with no warranties, and confers no rights. Alex Korchemniy

            M Offline
            M Offline
            Matt Gerrans
            wrote on last edited by
            #5

            That doesn't quite work by itself (I replaced "// change" with "cp.Style = cp.Style & ~1;"); you still see the window flash for a fraction of a second on startup. Matt Gerrans

            L 1 Reply Last reply
            0
            • M Matt Gerrans

              That doesn't quite work by itself (I replaced "// change" with "cp.Style = cp.Style & ~1;"); you still see the window flash for a fraction of a second on startup. Matt Gerrans

              L Offline
              L Offline
              LannieK
              wrote on last edited by
              #6

              Would setting the Location property in the Designer to have a Y value of, say, 3000, to put it off the display entirely, keep the flash from being seen?

              M 1 Reply Last reply
              0
              • L LannieK

                Would setting the Location property in the Designer to have a Y value of, say, 3000, to put it off the display entirely, keep the flash from being seen?

                M Offline
                M Offline
                Matt Gerrans
                wrote on last edited by
                #7

                I think that's just another kludge, so it would be just as well to stick with the minimized+not-in-taskbar. Most of the time the object oriented wrapping of the underlying Windows API mechanics is a benefit, but there are few rare cases when some things are a little more difficult. Hiding the main window on startup was also not obvious with MFC and Borland C++ Builder. If you ever wrote Windows apps "in the raw" it was pretty easy to control such things, but all the frameworks hide those details from you. Nevertheless, the productivity gain makes it well worth the price of dealing with the occassional quirk like this. After developing a few graphical apps in C#, there isn't much draw to going back to using the API in C. Matt Gerrans

                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