MFC,splash起動画面(改)

1960 ワード

 1 #ifndef _SPLASH_SCRN_

 2 #define _SPLASH_SCRN_

 3 

 4 

 5 // , , 

 6 #pragma once  

 7 // CWzdSplash  

 8 class CWzdSplash : public CWnd 9 { 10  DECLARE_DYNAMIC(CWzdSplash) 11 public: 12  CWzdSplash(); 13 virtual ~CWzdSplash(); 14 protected: 15  DECLARE_MESSAGE_MAP() 16 public: 17  CImage image; 18 void Create(); 19 afx_msg void OnPaint(); 20 21 }; 22 23 24 #endif
// WzdSplash.cpp :  

//



#include "stdafx.h" #include "Weather.h" #include "WzdSplash.h" // CWzdSplash IMPLEMENT_DYNAMIC(CWzdSplash, CWnd) CWzdSplash::CWzdSplash() { } CWzdSplash::~CWzdSplash() { } BEGIN_MESSAGE_MAP(CWzdSplash, CWnd) ON_WM_PAINT() END_MESSAGE_MAP() // CWzdSplash   void CWzdSplash::Create() { image.Load(_T("res/000.gif")); CBitmap m_bitmap; HBITMAP hbitmap = image.Detach(); BITMAP bitmap; m_bitmap.Attach(hbitmap); m_bitmap.GetBitmap(&bitmap); CreateEx(0,AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)), NULL, WS_POPUP | WS_VISIBLE, 0, 0, bitmap.bmWidth, bitmap.bmHeight, NULL, NULL); CWnd::CenterWindow(); CWnd::UpdateWindow(); } void CWzdSplash::OnPaint() { // TODO:   //   CWnd::OnPaint() CPaintDC dc(this); // device context forpainting image.Load(_T("res/000.gif")); image.Draw(dc.m_hDC, 1, 1);// draw bitmap  } // CWzdSplash  

 
 
説明:
 image.Load(_T("res/000.gif")); 。

OnCreat()

CWzdSplash wndSplash;//起動ウィンドウクラスのインスタンスwndSplashを作成します.Create(); Sleep(1000); wndSplash.DestroyWindow();//初期画面ウィンドウを破棄
 
完了