Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
Helo,
 
So, a while ago i wrote a long program that it takes a little to open, that is, i open the program and only many seconds later it appear on my screen, sometimes i even open 2 or 3 accidentally.
 
My program was written in C++ using visual studio forms and has many external images built in the exe.
 
How can i make like a loading screen so i know that the program was started but is loading?
 
Do i have to export image and my larger pieces of code to external resources like dll and then in the exe load those resources?
 
Cumpz,
Posted 24-Jun-12 9:55am
Cr4zYPT406
Comments
chandanadhikari at 26-Jun-12 11:29am
   
you can try implementing proxy pattern
not exactly a solution but this will not only help in solving this problem but might also better your coding style
 
look here :http://advancedcppwithexamples.blogspot.in/2010/10/c-example-of-proxy-design-pattern.html
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The term for this is a Splash Screen. There are several articles about those here on CodeProject.
 
Here is an excellent C++/MFC class: CSplashScreenEx : a non rectangular splash screen class with Alpha blending[^]
 
Soren Madsen
  Permalink  
Comments
Vitaly Tomilov at 24-Jun-12 17:09pm
   
Doh! Posted at the same time :) Good, +5 ;)
Sergey Alexandrovich Kryukov at 24-Jun-12 21:48pm
   
Right, a 5.
--SA
SoMad at 25-Jun-12 17:19pm
   
Thanks Sergey.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Your question is confusing as to which platform you used when writing your code. First, you say it is C++, and then you refer to forms in C++, which implies managed C++. The answer would depend very much on whether or not it is the managed platform.
 
Anyway, the best answer that would be universal here is this: just search for Splash Screen articles on CP. There are plenty of them, covering every platform that exists, including MFC (that's what I suspect you meant).
 
I would provide a list of links here, but it would be just a very long list, given the platform uncertainty.
  Permalink  
Comments
SoMad at 24-Jun-12 17:13pm
   
I agree, +5.
 
Soren Madsen
Sergey Alexandrovich Kryukov at 24-Jun-12 21:48pm
   
Agree, a 5.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

By visual studio forms I assume that you have created a Windows Forms application using C++/CLI.
 
Before trying anything else I would try the Native Image Generator (Ngen.exe)[^] - if you are really lucky this will be good enough.
 
Here is an article, A Pretty Good Splash Screen in C#[^], by Tom Clement - that shows how to create a splash screen for Windows Forms applications. It's c#, but it shows one way to create a splash screen.
 
To actually solve your problem, you need to create elements as needed, implementing some sort of lazy initialization for those parts that can be created after your program has started. The real performance hit occurs when the controls using your "large" resources are initialized.
 
Best regards
Espen Harlinn
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 24-Jun-12 21:48pm
   
Good reply, a 5.
--SA
Espen Harlinn at 25-Jun-12 3:25am
   
Thank you, Sergey :-)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

The use of a splash screen helps the user to know that the program is in the process of starting. However, it does not absolutely prevent the user from starting multiple instances of the same application. If you want to avoid opening multiple instances of an application, read this article: Avoiding Multiple Instances of an Application[^].
  Permalink  
Comments
SoMad at 26-Jun-12 20:44pm
   
I think this is a valid point. The OP does not say if he wants to be able to launch another instance later on. If he does want to limit the application to one instance, this is a good article to read.
 
Soren Madsen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,649
1 Sergey Alexandrovich Kryukov 6,270
2 CPallini 5,190
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 26 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100