Add splash screen control in VS2008

Source: Internet
Author: User
In VC6.0, you can do this by adding the splash component and then providing the function in the project invocation component. But there is no such component in the VS2008 (I have been looking for a long time, I did not find it, and there is no relevant information on the Internet). After reviewing the relevant information summarized as follows: 1, you need to add a special Class C Splashwnd. The code is as follows:
SplashWnd.h #ifndef _splash_header _ #define_SPLASH_HEADER_

#pragmaonce
#include "AFXWIN.h"

Csplashwnd

Classcsplashwnd:p ublic CWnd
{
Declare_dynamic (Csplashwnd)

Public
Csplashwnd ();
Virtual~csplashwnd ();
Virtualvoid PostNcDestroy ();

Public
CBitmap M_bitmap;

Protected
Staticbool C_bshowsplashwnd;
Staticcsplashwnd*c_psplashwnd;

Public
Staticvoid Enablesplashscreen (BOOL benable= TRUE);
Staticvoid ShowSplashScreen (cwnd*pparentwnd= NULL);
Staticbool pretranslateappmessage (msg*pmsg);

Protected
BOOL Create (cwnd*pparentwnd= NULL);
Voidhidesplashscreen ();

afx_msg int OnCreate (lpcreatestruct lpcreatestruct);
afx_msg void OnPaint ();
afx_msg void OnTimer (UINT nidevent);

Protected
Declare_message_map ()
};

#endif
SplashWnd.cpp//splashwnd.cpp: Implementing Files
//

#include "stdafx.h"
#include "resource.h"
#include "SplashWnd.h"


Csplashwnd

Implement_dynamic (Csplashwnd, CWnd)

BOOL Csplashwnd::c_bshowsplashwnd = FALSE;
Csplashwnd*csplashwnd::c_psplashwnd;

Csplashwnd::csplashwnd ()
{

}

Csplashwnd::~csplashwnd ()
{
Clear the static window pointer.
ASSERT (c_psplashwnd== this);
C_psplashwnd = NULL;
}


Begin_message_map (Csplashwnd, CWnd)
On_wm_create ()
On_wm_paint ()
On_wm_timer ()
End_message_map ()


Voidcsplashwnd::enablesplashscreen (BOOL benable)
{
C_bshowsplashwnd = benable;
}

Voidcsplashwnd::showsplashscreen (Cwnd*pparentwnd)
{
if (!c_bshowsplashwnd| | C_psplashwnd! = NULL)
Return
Allocate A new splash screen, and create the window.
c_psplashwnd= new Csplashwnd;
if (!c_psplashwnd->create (pParentWnd))
Delete C_psplashwnd;
Else
C_psplashwnd->updatewindow ();
}

BOOL Csplashwnd::P retranslateappmessage (msg*pmsg)
{
if (c_psplashwnd== NULL)
Returnfalse;

If we get a keyboard or mouse message, hide the splash screen.
if (pmsg->message== wm_keydown | |
pmsg->message== Wm_syskeydown | |
pmsg->message== Wm_lbuttondown | |
pmsg->message== Wm_rbuttondown | |
pmsg->message== Wm_mbuttondown | |
pmsg->message== Wm_nclbuttondown | |
pmsg->message== Wm_ncrbuttondown | |
pmsg->message== Wm_ncmbuttondown)
{
C_psplashwnd->hidesplashscreen ();
Returntrue; Message handled here
}

Returnfalse; Message not handled
}

BOOL csplashwnd::create (Cwnd*pparentwnd)
{
if (!m_bitmap. LoadBitmap (Idb_splash))
Returnfalse;

BITMAP BM;
M_bitmap. Getbitmap (&BM);

Returncreateex (0,
AfxRegisterWndClass (0, AfxGetApp ()->loadstandardcursor (Idc_arrow)),
NULL, Ws_popup | ws_visible,0,0, Bm.bmwidth, Bm.bmheight, Pparentwnd->getsafehwnd (), NULL);
}


Voidcsplashwnd::hidesplashscreen ()
{
Destroy the window, and update the mainframe.
DestroyWindow ();
AfxGetMainWnd ()->updatewindow ();
}

Voidcsplashwnd::P Ostncdestroy ()
{
Free the C + + class.
DeleteThis;
}

Intcsplashwnd::oncreate (lpcreatestruct lpcreatestruct)
{
if (cwnd::oncreate (lpcreatestruct) = =-1)
return-1;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.