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. Welcome dialog when app starts?

Welcome dialog when app starts?

Scheduled Pinned Locked Moved C#
csharpjsonquestion
8 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
    Andrey Kalganov
    wrote on last edited by
    #1

    Does anybody know how show "welcome" dialog while the the rest of the application is being loaded (C#)? Thanks a lot, Andrey

    D 1 Reply Last reply
    0
    • A Andrey Kalganov

      Does anybody know how show "welcome" dialog while the the rest of the application is being loaded (C#)? Thanks a lot, Andrey

      D Offline
      D Offline
      dazinith
      wrote on last edited by
      #2

      here is what im using in my apps:

      AboutBox myAboutBox = new AboutBox();
      myAboutBox.Show();
      myAboutBox.Refresh();
      // **************** SPLASH SCREEN UP *********************

      // do all of your loading here

      Thread.Sleep(1500); // sleep for a second and a half so it at least shows for a second.

      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      myAboutBox.Hide();
      myAboutBox.Dispose();
      // **************** SPLASH SCREEN DOWN *******************

      i find that you need to call the Refresh() before doing anything cpu intensive or it might not show cause its too busy processing other stuff.. still a newb.. cut me some slack :P -dz

      J 1 Reply Last reply
      0
      • D dazinith

        here is what im using in my apps:

        AboutBox myAboutBox = new AboutBox();
        myAboutBox.Show();
        myAboutBox.Refresh();
        // **************** SPLASH SCREEN UP *********************

        // do all of your loading here

        Thread.Sleep(1500); // sleep for a second and a half so it at least shows for a second.

        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();

        myAboutBox.Hide();
        myAboutBox.Dispose();
        // **************** SPLASH SCREEN DOWN *******************

        i find that you need to call the Refresh() before doing anything cpu intensive or it might not show cause its too busy processing other stuff.. still a newb.. cut me some slack :P -dz

        J Offline
        J Offline
        Jose Fco Bonnin
        wrote on last edited by
        #3

        If you do a Thread.Sleep the rest of the application will not be loaded. Why don't you try something like that public class Form1 : System.Windows.Forms.Form { .... Form2 frm= new Form2(); public Form1() { Thread thread = new Thread(new ThreadStart(StartForm2)); thread.Start(); // Do your stuff frm.Close(); } private void StartForm2() { if (frm != null) frm.ShowDialog(); } .... }

        D 1 Reply Last reply
        0
        • J Jose Fco Bonnin

          If you do a Thread.Sleep the rest of the application will not be loaded. Why don't you try something like that public class Form1 : System.Windows.Forms.Form { .... Form2 frm= new Form2(); public Form1() { Thread thread = new Thread(new ThreadStart(StartForm2)); thread.Start(); // Do your stuff frm.Close(); } private void StartForm2() { if (frm != null) frm.ShowDialog(); } .... }

          D Offline
          D Offline
          dazinith
          wrote on last edited by
          #4

          if you look back at my code you'll see that the Thread.Sleep(1500) is just to pause for a second.. i know nothing is going to happen during that time.. right above that is where i load all of my stuff.. i just pause so that the splash screen is showed for at least a second, it serves no other purpose and can be removed. this is all in my constructor for my main form.. what is the benefit of creating a thread just to show and close the dialog when you could just show and hide the dialog around the section of code that does your loading?

          AboutBox myAboutBox = new AboutBox();
          myAboutBox.Show();
          myAboutBox.Refresh();
          // **************** SPLASH SCREEN UP *********************

          // do all of your loading here <--- this is where i do all my loading..

          // sleep for a second and a half so it at least shows for a second.
          Thread.Sleep(1500); // <---this can be removed, its not necessary, i just do it

          //// Required for Windows Form Designer support//
          InitializeComponent();

          myAboutBox.Hide();
          myAboutBox.Dispose();
          // **************** SPLASH SCREEN DOWN *******************

          still a newb.. cut me some slack :P -dz

          J 1 Reply Last reply
          0
          • D dazinith

            if you look back at my code you'll see that the Thread.Sleep(1500) is just to pause for a second.. i know nothing is going to happen during that time.. right above that is where i load all of my stuff.. i just pause so that the splash screen is showed for at least a second, it serves no other purpose and can be removed. this is all in my constructor for my main form.. what is the benefit of creating a thread just to show and close the dialog when you could just show and hide the dialog around the section of code that does your loading?

            AboutBox myAboutBox = new AboutBox();
            myAboutBox.Show();
            myAboutBox.Refresh();
            // **************** SPLASH SCREEN UP *********************

            // do all of your loading here <--- this is where i do all my loading..

            // sleep for a second and a half so it at least shows for a second.
            Thread.Sleep(1500); // <---this can be removed, its not necessary, i just do it

            //// Required for Windows Form Designer support//
            InitializeComponent();

            myAboutBox.Hide();
            myAboutBox.Dispose();
            // **************** SPLASH SCREEN DOWN *******************

            still a newb.. cut me some slack :P -dz

            J Offline
            J Offline
            Jose Fco Bonnin
            wrote on last edited by
            #5

            I'm sorry if I'm offended you I didn't want to criticize your code. What I'm saying is if that guy wants to show a form during the load of the real application, in my opinion is better to show it in a different thread because it guarantees that the form will be shown and you will not get a blank screen because the application is busy doing other things. But of course you can also use tricks like Refresh() or Application.DoEvents() doesn't matter.

            D 1 Reply Last reply
            0
            • J Jose Fco Bonnin

              I'm sorry if I'm offended you I didn't want to criticize your code. What I'm saying is if that guy wants to show a form during the load of the real application, in my opinion is better to show it in a different thread because it guarantees that the form will be shown and you will not get a blank screen because the application is busy doing other things. But of course you can also use tricks like Refresh() or Application.DoEvents() doesn't matter.

              D Offline
              D Offline
              dazinith
              wrote on last edited by
              #6

              ah.. i was wondering why i had to refresh the form to make it show.. i guess i can see how having another thread could help them both.. especially if you wanted your loading form to have some sort of animation or something.. btw, i wasnt offended, i honestly wanted to know the purpose :) still a newb.. cut me some slack :P -dz

              A 1 Reply Last reply
              0
              • D dazinith

                ah.. i was wondering why i had to refresh the form to make it show.. i guess i can see how having another thread could help them both.. especially if you wanted your loading form to have some sort of animation or something.. btw, i wasnt offended, i honestly wanted to know the purpose :) still a newb.. cut me some slack :P -dz

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                Thanks guys for your replies. Jose, when I try to close the "start" form, the main form losts focus. Any ideas how to dial with that? ------------------------ Andrey

                D 1 Reply Last reply
                0
                • A Anonymous

                  Thanks guys for your replies. Jose, when I try to close the "start" form, the main form losts focus. Any ideas how to dial with that? ------------------------ Andrey

                  D Offline
                  D Offline
                  dazinith
                  wrote on last edited by
                  #8

                  my guess is that if you just called Focus() it would get focus back Form1.Focus(); thats my guess :) still a newb.. cut me some slack :P -dz

                  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