Solved

Using Timer for splash screen

Posted on 1998-09-09
5
257 Views
Last Modified: 2013-11-20
Hi, I want to use timer to control the splash screen at the start of my dialog based app., how can I do that? Please describe complete procedure step by step.
Waiting for help
0
Comment
Question by:Moin
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Andy_Keys
Comment Utility
You could add the splash screen component this does it for you
0
 

Author Comment

by:Moin
Comment Utility
But splash screen component work in doc/view architecture, where CMainFrm is present. I  want to ask how to put it in dialog based app.
0
 
LVL 1

Expert Comment

by:Andy_Keys
Comment Utility
I've look at one I've used and can't see why you think its dependant upon CMainFrm.
0
 
LVL 1

Accepted Solution

by:
plebel earned 20 total points
Comment Utility
personely, i use a my about box (a CDialog based class).
My about box is caption free and screen centered.
When i use it as a splash screen, i hide the "OK" button and i close it by the timer.

here is the code (which is not a big secret anyway)

By the way, i use the "int GoAbout(UINT Idd)" function to open it as a dialog and "BOOL SplashOn(UINT Idd)" function to open it as a splash screen





// About.h : header file
//

BOOL SplashOn(UINT Idd, LPTSTR lpKeySubClass = 0, LPTSTR lpKeySubClass1 = 0);
void SplashOff();
int GoAbout(UINT Idd);
 

#define IDC_INFO 100
#define IDB_DEMO 101

/////////////////////////////////////////////////////////////////////////////
// CAbout dialog

class CAbout : public CDialog
{
// Construction
public:
      CAbout(UINT Idd,BOOL bSplash,CWnd* pParent = NULL);   // standard constructor

// Dialog Data
      //{{AFX_DATA(CAbout)
      //enum { IDD = IDD_ABOUT };
            // NOTE: the ClassWizard will add data members here
      //}}AFX_DATA


// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CAbout)
      public:
      virtual BOOL DestroyWindow();
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Implementation
protected:

      // Generated message map functions
      //{{AFX_MSG(CAbout)
      virtual BOOL OnInitDialog();
      afx_msg void OnTimer(UINT nIDEvent);
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
private:
      BOOL m_bTimer;
      BOOL m_bSplash;
      HINSTANCE m_hInstance;
};

// CAbout dialog
////////////

/////////////////////
// About.cpp : implementation file
//

#include "stdafx.h"
#include "About.h"



#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

static CAbout *pAbout = NULL;




BOOL SplashOn(UINT Idd)
{
      if (!pAbout)
      {
            pAbout = new CAbout(Idd,TRUE);
            pAbout->Create(Idd);
            pAbout->ShowWindow(SW_SHOW);
            pAbout->UpdateWindow();
      }
      return TRUE;
}

void SplashOff()
{
      if (pAbout)
      {
            pAbout->DestroyWindow();
            delete pAbout;
            pAbout = NULL;
      }
}

int GoAbout(UINT Idd)
{
      CAbout About(Idd,FALSE);
      About.DoModal();
      return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAbout dialog


CAbout::CAbout(UINT Idd,BOOL bSplash,CWnd* pParent /*=NULL*/)
      : CDialog(Idd, pParent), CVersionInfo()
{
      //{{AFX_DATA_INIT(CAbout)
            // NOTE: the ClassWizard will add member initialization here
      //}}AFX_DATA_INIT

      m_bSplash = bSplash;
      m_hInstance = AfxGetInstanceHandle();

}


void CAbout::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CAbout)
            // NOTE: the ClassWizard will add DDX and DDV calls here
      //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAbout, CDialog)
      //{{AFX_MSG_MAP(CAbout)
      ON_WM_TIMER()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAbout message handlers

BOOL CAbout::OnInitDialog()
{
      CDialog::OnInitDialog();
      
      // TODO: Add extra initialization here

      if (m_bSplash)
      {
             GetDlgItem( IDOK )->ShowWindow(SW_HIDE);

             // set timer for 5 sec
             SetTimer(1,5000,0);
                                                       
             m_bTimer = TRUE;
      }
      else
      {
            m_bTimer = FALSE;
      }
      

      return TRUE;
}

BOOL CAbout::DestroyWindow()
{

      if (m_bTimer)
      {
            KillTimer(1);
            m_bTimer = 0;
      }
      return CDialog::DestroyWindow();
}

void CAbout::OnTimer(UINT nIDEvent)
{
      if (nIDEvent == 1)
            SplashOff();            
}


0
 
LVL 1

Expert Comment

by:plebel
Comment Utility
better replace
BOOL SplashOn(UINT Idd, LPTSTR lpKeySubClass = 0, LPTSTR lpKeySubClass1 = 0);

by
BOOL SplashOn(UINT Idd);


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

8 Experts available now in Live!

Get 1:1 Help Now