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 / C++ / MFC
  4. Splash Screen Window problem

Splash Screen Window problem

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdockerhelplearning
7 Posts 3 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.
  • G Offline
    G Offline
    gr8coaster329
    wrote on last edited by
    #1

    I have just added a splash screen to my program. i can compile it without errors but when i try to run it the splash screen does not exit and it continually opens the next window, until i endup with about 10 windows and i close the program. i am not sure what code is causing the problem so i will just post the splash screen form code:

    #pragma once

    #include "Form1.h"

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    namespace MyProgram
    {
    /// /// Summary for frm_splash_screen
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    /// 'Resource File Name' property for the managed resource compiler tool
    /// associated with all .resx files this class depends on. Otherwise,
    /// the designers will not be able to interact properly with localized
    /// resources associated with this form.
    ///
    public ref class frm_splash_screen : public System::Windows::Forms::Form
    {
    public:
    frm_splash_screen(void)
    {
    InitializeComponent();
    //
    //TODO: Add the constructor code here
    //
    }

    protected:
    	/// /// Clean up any resources being used.
    	/// 
    	/// "description of the parameter"
    	virtual void Dispose(Boolean disposing) override
    	{
    		if (disposing && components)
    		{
    			delete components;
    		}
    		\_\_super::Dispose(disposing);
    	}
    private: System::Windows::Forms::Label^  lbl\_splash\_screen;
    private: System::Windows::Forms::Timer^  timer1;
    private: System::Windows::Forms::PictureBox^  pictureBox1;
    private: System::ComponentModel::IContainer^  components;
    protected: 
    
    private:
    	/// /// Required designer variable.
    	/// 
    

    #pragma region Windows Form Designer generated code
    /// /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    ///
    void InitializeComponent(void)
    {
    this->components = (gcnew System::ComponentModel::Container());
    System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(frm_splash_screen::typeid));
    this->lbl_splash_screen = (gcnew System::Windows::Forms::Label());
    this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));

    C P 2 Replies Last reply
    0
    • G gr8coaster329

      I have just added a splash screen to my program. i can compile it without errors but when i try to run it the splash screen does not exit and it continually opens the next window, until i endup with about 10 windows and i close the program. i am not sure what code is causing the problem so i will just post the splash screen form code:

      #pragma once

      #include "Form1.h"

      using namespace System;
      using namespace System::ComponentModel;
      using namespace System::Collections;
      using namespace System::Windows::Forms;
      using namespace System::Data;
      using namespace System::Drawing;

      namespace MyProgram
      {
      /// /// Summary for frm_splash_screen
      ///
      /// WARNING: If you change the name of this class, you will need to change the
      /// 'Resource File Name' property for the managed resource compiler tool
      /// associated with all .resx files this class depends on. Otherwise,
      /// the designers will not be able to interact properly with localized
      /// resources associated with this form.
      ///
      public ref class frm_splash_screen : public System::Windows::Forms::Form
      {
      public:
      frm_splash_screen(void)
      {
      InitializeComponent();
      //
      //TODO: Add the constructor code here
      //
      }

      protected:
      	/// /// Clean up any resources being used.
      	/// 
      	/// "description of the parameter"
      	virtual void Dispose(Boolean disposing) override
      	{
      		if (disposing && components)
      		{
      			delete components;
      		}
      		\_\_super::Dispose(disposing);
      	}
      private: System::Windows::Forms::Label^  lbl\_splash\_screen;
      private: System::Windows::Forms::Timer^  timer1;
      private: System::Windows::Forms::PictureBox^  pictureBox1;
      private: System::ComponentModel::IContainer^  components;
      protected: 
      
      private:
      	/// /// Required designer variable.
      	/// 
      

      #pragma region Windows Form Designer generated code
      /// /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      ///
      void InitializeComponent(void)
      {
      this->components = (gcnew System::ComponentModel::Container());
      System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(frm_splash_screen::typeid));
      this->lbl_splash_screen = (gcnew System::Windows::Forms::Label());
      this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This is not the MC++ forum, the C++/CLI forum is. Personally, I don't think the splash screen should be responsible for showing the main form, and it can't work in this case, as ShowDialog is a modal call, this->Close won't run until the dialog closes. If you wanted to stick with this design ( which as I said, is poor in my opinion ), then you could *hide* the splash screen, which will mean it will use memory while your app is running. Or you could change the code so that the main entry point shows the splash screen, and when it closes itself, it goes on to run the main window. However, if there's no thread doing initialisation, why would you waste users time with a splash screen ? Also, I think there's a built in splash screen component. Can I ask why you're using MC++ ? I'm just interested because I can't imagine ever choosing to use it. Christian Graus - Microsoft MVP - C++

      G 1 Reply Last reply
      0
      • C Christian Graus

        This is not the MC++ forum, the C++/CLI forum is. Personally, I don't think the splash screen should be responsible for showing the main form, and it can't work in this case, as ShowDialog is a modal call, this->Close won't run until the dialog closes. If you wanted to stick with this design ( which as I said, is poor in my opinion ), then you could *hide* the splash screen, which will mean it will use memory while your app is running. Or you could change the code so that the main entry point shows the splash screen, and when it closes itself, it goes on to run the main window. However, if there's no thread doing initialisation, why would you waste users time with a splash screen ? Also, I think there's a built in splash screen component. Can I ask why you're using MC++ ? I'm just interested because I can't imagine ever choosing to use it. Christian Graus - Microsoft MVP - C++

        G Offline
        G Offline
        gr8coaster329
        wrote on last edited by
        #3

        i am using microsoft visual c++ express editon 2005 and i dont think it has a built in component like that. it was the first way i thought of and i thought it would work but obviously it doesnt. how would i go about writing the code so that it does it the way that you stated. i dont want it to be using memory the entire time the programs running it would slow it down too much. if you could give me an idea on how to do this it would be greatly appreciated, thank you. - Kyle

        C 1 Reply Last reply
        0
        • G gr8coaster329

          i am using microsoft visual c++ express editon 2005 and i dont think it has a built in component like that. it was the first way i thought of and i thought it would work but obviously it doesnt. how would i go about writing the code so that it does it the way that you stated. i dont want it to be using memory the entire time the programs running it would slow it down too much. if you could give me an idea on how to do this it would be greatly appreciated, thank you. - Kyle

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          gr8coaster329 wrote: i am using microsoft visual c++ express editon 2005 and i dont think it has a built in component like that. Possibly. gr8coaster329 wrote: how would i go about writing the code so that it does it the way that you stated. The code that creates the splash screen should call ShowDialog to show it, then have the code to create the main form directly after. Then, when your splash screen closes itself, the next bit of code will create the main form. So, why did you decide to use managed C++ ? Christian Graus - Microsoft MVP - C++

          G 1 Reply Last reply
          0
          • C Christian Graus

            gr8coaster329 wrote: i am using microsoft visual c++ express editon 2005 and i dont think it has a built in component like that. Possibly. gr8coaster329 wrote: how would i go about writing the code so that it does it the way that you stated. The code that creates the splash screen should call ShowDialog to show it, then have the code to create the main form directly after. Then, when your splash screen closes itself, the next bit of code will create the main form. So, why did you decide to use managed C++ ? Christian Graus - Microsoft MVP - C++

            G Offline
            G Offline
            gr8coaster329
            wrote on last edited by
            #5

            i use managed c++ because it is what is used in microsofft visual c++ EE 2005. i used it because it was the first free visual c++ compiler that was like what i wanted so i just use it. it works fine for me. if you know of any good programs like this that are better i would try it but i just do programming as a hobby right now and i cant afford to buy software. Thank you for your help - Kyle

            C 1 Reply Last reply
            0
            • G gr8coaster329

              i use managed c++ because it is what is used in microsofft visual c++ EE 2005. i used it because it was the first free visual c++ compiler that was like what i wanted so i just use it. it works fine for me. if you know of any good programs like this that are better i would try it but i just do programming as a hobby right now and i cant afford to buy software. Thank you for your help - Kyle

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Are you honestly saying that 2005 EE ONLY lets you use managed C++ ? Do you realise the difference between this and C++ ? You're wrong, you can build C++ applications with EE 2005, you don't need to use managed extensions. I just checked the Microsoft site. gr8coaster329 wrote: but i just do programming as a hobby right now and i cant afford to buy software. If you're learning, you should learn C++ first, then MC++. This way, you're essentially learning two languages at once. MC++ is C++ with additional constructs that let you use the .NET framework ( which means your app requires the .NET framework 2.0 to run ). You should write some console apps first, then some MFC apps before moving to MC++, and if you still want to, you should learn C# instead. I don't see any reason to use MC++ except to write bridging dlls between C++ SDKs and C#. *edit* actually I don't think the free version offers MFC or ATL. Which means you're stuck with MC++ or Win32 SDK style code for windows apps, I guess. Christian Graus - Microsoft MVP - C++

              1 Reply Last reply
              0
              • G gr8coaster329

                I have just added a splash screen to my program. i can compile it without errors but when i try to run it the splash screen does not exit and it continually opens the next window, until i endup with about 10 windows and i close the program. i am not sure what code is causing the problem so i will just post the splash screen form code:

                #pragma once

                #include "Form1.h"

                using namespace System;
                using namespace System::ComponentModel;
                using namespace System::Collections;
                using namespace System::Windows::Forms;
                using namespace System::Data;
                using namespace System::Drawing;

                namespace MyProgram
                {
                /// /// Summary for frm_splash_screen
                ///
                /// WARNING: If you change the name of this class, you will need to change the
                /// 'Resource File Name' property for the managed resource compiler tool
                /// associated with all .resx files this class depends on. Otherwise,
                /// the designers will not be able to interact properly with localized
                /// resources associated with this form.
                ///
                public ref class frm_splash_screen : public System::Windows::Forms::Form
                {
                public:
                frm_splash_screen(void)
                {
                InitializeComponent();
                //
                //TODO: Add the constructor code here
                //
                }

                protected:
                	/// /// Clean up any resources being used.
                	/// 
                	/// "description of the parameter"
                	virtual void Dispose(Boolean disposing) override
                	{
                		if (disposing && components)
                		{
                			delete components;
                		}
                		\_\_super::Dispose(disposing);
                	}
                private: System::Windows::Forms::Label^  lbl\_splash\_screen;
                private: System::Windows::Forms::Timer^  timer1;
                private: System::Windows::Forms::PictureBox^  pictureBox1;
                private: System::ComponentModel::IContainer^  components;
                protected: 
                
                private:
                	/// /// Required designer variable.
                	/// 
                

                #pragma region Windows Form Designer generated code
                /// /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                ///
                void InitializeComponent(void)
                {
                this->components = (gcnew System::ComponentModel::Container());
                System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(frm_splash_screen::typeid));
                this->lbl_splash_screen = (gcnew System::Windows::Forms::Label());
                this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));

                P Offline
                P Offline
                Phil J Pearson
                wrote on last edited by
                #7

                I agree with all that Christian has said about the design being inappropriate but that's up to you. The simple answer to the problem you have is that your timer event handler cmd_time_reached is not a member of the frm_splash_screen class so this->Close() will not close the splash screen (this doesn't point to it). You don't show how the splash screen is created but you could keep a handle to it and do SplashScreen->Close()


                The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).

                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