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. Application.Run question

Application.Run question

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

    Hi all, I've a question about Application.Run, which is supposed to start the main loop for receiving messages for windows.forms applications. What I want to do is hide the form on startup, which I do either with setting the Visibility property to false or calling Hide(); so far no problems with that. But when I start the loop with Application.Run(form); it makes the form visible. The thing is that it makes the form visible after calling the constructor so what's the proper way of starting a form with Application.Run(Form); which will be hidden? Any advice is appreaciated ;) Regards

    M O D P 4 Replies Last reply
    0
    • 1 1nsp1r3d

      Hi all, I've a question about Application.Run, which is supposed to start the main loop for receiving messages for windows.forms applications. What I want to do is hide the form on startup, which I do either with setting the Visibility property to false or calling Hide(); so far no problems with that. But when I start the loop with Application.Run(form); it makes the form visible. The thing is that it makes the form visible after calling the constructor so what's the proper way of starting a form with Application.Run(Form); which will be hidden? Any advice is appreaciated ;) Regards

      M Offline
      M Offline
      MoustafaS
      wrote on last edited by
      #2

      In this form Load event just call : Hide();.

      D 1 Reply Last reply
      0
      • 1 1nsp1r3d

        Hi all, I've a question about Application.Run, which is supposed to start the main loop for receiving messages for windows.forms applications. What I want to do is hide the form on startup, which I do either with setting the Visibility property to false or calling Hide(); so far no problems with that. But when I start the loop with Application.Run(form); it makes the form visible. The thing is that it makes the form visible after calling the constructor so what's the proper way of starting a form with Application.Run(Form); which will be hidden? Any advice is appreaciated ;) Regards

        O Offline
        O Offline
        occcy
        wrote on last edited by
        #3

        private void Form1_Activated(object sender, System.EventArgs e) { this.Visible=false; }

        1 Reply Last reply
        0
        • 1 1nsp1r3d

          Hi all, I've a question about Application.Run, which is supposed to start the main loop for receiving messages for windows.forms applications. What I want to do is hide the form on startup, which I do either with setting the Visibility property to false or calling Hide(); so far no problems with that. But when I start the loop with Application.Run(form); it makes the form visible. The thing is that it makes the form visible after calling the constructor so what's the proper way of starting a form with Application.Run(Form); which will be hidden? Any advice is appreaciated ;) Regards

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Now I remember how I did it. It helps to go back and actually look at the damn code! Override OnLoad and set the form's Opacity to 0. When you need to show the form, reset the Opacity to 1. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • M MoustafaS

            In this form Load event just call : Hide();.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            That doesn't work. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            1 Reply Last reply
            0
            • 1 1nsp1r3d

              Hi all, I've a question about Application.Run, which is supposed to start the main loop for receiving messages for windows.forms applications. What I want to do is hide the form on startup, which I do either with setting the Visibility property to false or calling Hide(); so far no problems with that. But when I start the loop with Application.Run(form); it makes the form visible. The thing is that it makes the form visible after calling the constructor so what's the proper way of starting a form with Application.Run(Form); which will be hidden? Any advice is appreaciated ;) Regards

              P Offline
              P Offline
              Paul Voicu
              wrote on last edited by
              #6

              What else do you want to do other than hiding the (main) form of the application? I assume you want to launch another form for login or splash or something similar. I suggest placing the code that you want to execute while keeping your form hidden in the OnLoad event delegate of that form. At some point, you will return from that code and continue with the execution of the delegate. I guess you could set the Visible property to false within the OnLoad delegate, but then what do you get to do in your application? Maybe I didn't understand your desired behavior, but I suggest using the form's OnLoad delegate, because before that delegate is finished the form is not shown.

              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