?
Solved

How do I show a splash screen??

Posted on 1998-01-24
11
Medium Priority
?
324 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 40 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

762 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