Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Comments
chandanadhikari 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

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
 
Share this answer
 
Comments
Vitaly Tomilov 24-Jun-12 17:09pm    
Doh! Posted at the same time :) Good, +5 ;)
Sergey Alexandrovich Kryukov 24-Jun-12 21:48pm    
Right, a 5.
--SA
SoMad 25-Jun-12 17:19pm    
Thanks Sergey.
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.
 
Share this answer
 
Comments
SoMad 24-Jun-12 17:13pm    
I agree, +5.

Soren Madsen
Sergey Alexandrovich Kryukov 24-Jun-12 21:48pm    
Agree, a 5.
--SA
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
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Jun-12 21:48pm    
Good reply, a 5.
--SA
Espen Harlinn 25-Jun-12 3:25am    
Thank you, Sergey :-)
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[^].
 
Share this answer
 
Comments
SoMad 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900