Using TSplashWindow




Date: 7 March 1997 
Author: Brice VIDAL 
Platform: 32 bit environment 
In memory of: Carcass 

Overview

The TSplashWindow class

#include <owl/gdiobjec.h>  
#include <owl/splashwi.h>  

TDib splashDib("splash.bmp");  

TSplashWindow(splashDib, splashDib.Width() + 10, splashDib.Heigth() + 10);

int style =  TSplashWindow::MakeStatic   |  
             TSplashWindow::MakeGauge    |  
             TSplashWindow::CaptureMouse |  
             TSplashWindow::ShrinkToFit;  
   
int timeOut = 10000;  

TDib splashDib("splash.bmp");  

TSplashWindow splashWindow(splashDib, 00, style, timeOut);

Using the splash screen

The splash screen can be created whenever needed. Generally the splash window is created when the application starts will be the more usual and then destroying it when the client is ready.  

#include <owl/applicat.h>  
#include <owl/gdiobjec.h>  
#include <owl/splashwi.h>  

TSplashWindow* splashWindow;   

class TSplashApp : public TApplication  
{  
  public:  
    TSplashApp() : TApplication("Splash Screen Demo")  
    {  
      int style = TSplashWindow::MakeStatic   |  
                  TSplashWindow::MakeGauge    |  
                  TSplashWindow::CaptureMouse |  
                  TSplashWindow::ShrinkToFit;  
   
      int timeOut = 10000;  

      splashWindow = new TSplashWindow(*new TDib("splash.bmp"), 00, style, timeOut);  
      splashWindow->Create(); // create the splash window  
      splashWindow->UpdateWindow(); // update the display to show the splash screen  

      sleep(5); // wait 5 seconds, only for this example  
    }  

    ~TSplashApp(){}  

    void InitMainWindow()  
    {  
      TApplication::InitMainWindow();  

      delete splashWindow;  
    }  
};  

int OwlMain(int , char* [])  
{  
  TSplashApp app;  
  return app.Run();  
}

#include <owl/applicat.h>  
#include <owl/gdiobjec.h>  
#include <owl/splashwi.h>  

TSplashWindow* splashWindow;   
TDib splashDib("splash.bmp");  

class TSplashApp : public TApplication  
{  
    public:  
    TSplashApp() : TApplication("Splash Screen Demo")  
    {  
       int style = TSplashWindow::MakeStatic |  
                   TSplashWindow::MakeGauge |  
                   TSplashWindow::CaptureMouse;  
   
       int timeOut = 10000;  

       splashWindow = new TSplashWindow(splashDib, splashDib.Width(), 
                                        splashDib.Heigth() + 100, style, timeOut);  

       splashWindow->Create(); // create the splash window  
       splashWindow->UpdateWindow(); // update the display to show the splash screen  

       splashWindow->SetText("Splash Window Created");  
       splashWindow->SetPercentDone(25);  

       sleep(5); // wait 5 seconds, only for this example  
       splashWindow->SetText("Delay Ended"); 
       splashWindow->SetPercentDone(50); 

    }  

    ~TSplashApp(){}  

    void InitMainWindow()  
    {  
        splashWindow->SetText("Initializaing the main Window"); 
        splashWindow->SetPercentDone(75); 
  
        TApplication::InitMainWindow();  

        splashWindow->SetText("Deleting SplashWindow"); 
        splashWindow->SetPercentDone(100);  

        sleep(3); 

        delete splashWindow;  
    }  
};



As you have seen, the splash window does not really look great and we cannot do all we want with the controls: we can't size them precisely, put them where we want, change the colors or the font, we can only put one control of each, we can't add a particular control such as a TAnimateCtrl, ... 

Most of the time a simple image will fit for a splash screen as application don't take too long to open but if needed you can, embed the splash screen by either creating a whole splash screen (probably basing it on the TDialog class so that you can use Resource Workshop to design it) or using TSplashWindow as a base class of your splash window class and changing the code so it can do what you want exactly (therefore you will need to access to it's private members). In both cases there is one thing really important: the messages. Your object will need to pump the waiting messages sent to it ...

You can also wait for the next version of OWL. Have a normal day!