Solved

How do I show a splash screen??

Posted on 1998-01-24
11
258 Views
Last Modified: 2008-03-03
When my program is loading how do I have a splash screen (with an image) come up for a few seconds (as everything else is loading)??
0
Comment
Question by:stevenc317
  • 5
  • 5
11 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1178831
If you are programming with VC++ you can add splash screen using component galerry. Go to Project->Add To Project->component and Controls. Choose "Developer Studio Components" and then "Splash screen". The necessary code will be automatically added to your project so your responsibility is only to change splash bitmap.
0
 
LVL 1

Author Comment

by:stevenc317
ID: 1178832
Sorry I am using Borland C++ Builder v1.0 for Win95
0
 
LVL 22

Accepted Solution

by:
nietod earned 10 total points
ID: 1178833
The basic idea is to display a window whose contents are a bitmap (or other image, I suppose).  

You cannot do this during load time, but you can do it early in the initialization pocess.

In my case the "lowest" DLL  (a dll that is used by other Dll's and the EXE, but that does not use any other Dll) creates the window during process attach and stores its handle in a global variable.  When the exe is done initializing it calls a function in the Dll that destroyes the window.

To make things a little nicer.  I have the Dll look in the EXE's resources for the bitmap to display so different EXE's can use the DLL and get different bitmaps.  If no bitmap with the desired names is found, it doesn't put up the splash screen.  Also I have the splash screen divide in half.  There is a picture in one half and a text "console" in the other falf.  As the other libraries initialize, they print progress messages to the console.  Not only is this reasuring to the user (to not have an awkward wait where nothing seems to be occuring) but it can help track down bugs during initialization.

I can provide more details on how to create the window/ displayt he bitmap/ handle the process attach etc, if you need them.

0
 
LVL 1

Author Comment

by:stevenc317
ID: 1178834
please tell me the codes that i need, I am a very basic C++ prgrammer.  I have Borland C++ Builder v1.0 for Win 95 (that is the newest version)
0
 
LVL 22

Expert Comment

by:nietod
ID: 1178835
well there is a lot involved here.  Do you have specific questions?  For example, so you know how to create a window? (If not then you are probably asking that wrong question because your application should handle windows long before it handles splash screens.) Do you know how to add a bitmap to the resources?  Do you know how to load and display a bitmap?  I can help you with this stuff, but it is the core of windows programming and I don't want to waste time explaining things that you already know.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:stevenc317
ID: 1178836
Good point.  I just need the following.
1) How do I have the window "SplashScreen1" come up as soon as the app loads??

2) How do I have "SplashScreen1" close after 5 seconds???

thanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 1178837
(1)  You can't display the splash screen when the program loads.  You have to wait until you get cntrol from windows.  How long you have to wait is going to depend.  I'll sketch a couple of possibilities.  

If the splash screen is created by the application (rather than a Dll), you could just put code at the start of WinMain() to create the window then do you program initialization stuff.  

However if your program does a lot of initialization stuff using global objects.  These objects will be initialized before WinMain() is called so there will be a noticable wait before the splash screen appears.  If that is the case, you can create a class that creates a splash screen in its constructor.  Then just create a global object of this class at the start of your program (global objects are initialized from the top of the file (translation unit) to the bottom, that is a C++ requirement.)  This causes the splash screen to display before any other objects are initalized and before winmain() is called.

If your exe uses Dll's that take a long time to initialize, then you may still have a long lag before the screen appears.  This is harder to fix perfectly.  But in this case you can create a Dll that displays the splash screen when it attaches to a process.  The Dll will be attached to you process even before your globals are initialized.  However you can't force the Dll to be attached before other Dll's.  However, if you've written all (or at least some) of the other Dll's. You can make them use the splash screen Dll so it will load first.  It will have to use a semaphore to prevent the creation of multiple splah screens in this case.


0
 
LVL 22

Expert Comment

by:nietod
ID: 1178838
(2)  I would display the splash screen during initialization, regardless of how long it takes--unless you know you have minimum initialization to perform.

You can use SetTimer() to set a timer that will notify the splash screen window when it should close.  The window will receive a WM_TIMER message when the timer expires.  The handler for this message can close the window and destroy the timer (KillTimer()).

You could make the window be destroyed when two conditions are satisfied.  (1) it has received the timer notification.  (2) the application has notified it that initialization is complete.

I can give more details on any of these possiblilites if you need them.  I just don't want to elaborate on all of them.  If you're not sure what technique is best, you might want to try describing you application here.  (In terms of complexity, initialization requirements, and ExE/Dll design and usage.)
0
 
LVL 1

Author Comment

by:stevenc317
ID: 1178839
Ok for question one I think I am going to need to post my source code.  For question two, can you tell me the codes to close the window (I found out about the time, so don't worry about that part).

thanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 1178840
To close a window you just use DestroyWindow().  

Does that answer your question?  If not ask again, I'm having trouble understanding exactly what you are asking.  
0
 
LVL 1

Author Comment

by:stevenc317
ID: 1178841
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now