В прошлом шаге мы добавили заставку. Во-первых, сама картинка заставки в данном варианте это растр, который берется из ресурса в момент создания заставки.
BOOL CSplashWnd::Create(CWnd* pParentWnd /*= NULL*/) { if (!m_bitmap.LoadBitmap(IDB_SPLASH)) return FALSE; BITMAP bm; m_bitmap.GetBitmap(&bm); return CreateEx(0, AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)), NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL); }
Идентификатор у него IDB_SPLASH, и если Вы захотите удалите готовый, поместите свой, но с данным идентификатором. Вызывается заставка сразу после создания объектов окна.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { ....... // CG: The following line was added by the Splash Screen component. CSplashWnd::ShowSplashScreen(this); return 0; }
А убирается по таймеру.
void CSplashWnd::OnTimer(UINT nIDEvent) { // Destroy the splash screen window. HideSplashScreen(); }
Который устанавливается при ее создании.
int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; // Center the window. CenterWindow(); // Set a timer to destroy the splash screen. SetTimer(1, 750, NULL); return 0; }
Ну, а чтобы совсем было понятно, в функции ShowSplashScreen заставка и создается.
void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/) { 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(); }