Solved

How do I show a splash screen??

Posted on 1998-01-24
11
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I could not build boost code, 10 107
sorting efficency of sorting algorithm 30 132
How to determine if the result of an equation is an integer in C++? 3 29
Finding Divisors 5 39
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

733 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