Solved

How do I show a splash screen??

Posted on 1998-01-24
11
289 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
getting a fire fox page (view page source ) in c++ 6 42
Least Squares Curve Fitting 4 99
HTTPSendRequest with WinINet delays on first call 11 36
C++ help/ Toy problem 19 30
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

832 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