首页 > 代码库 > MFC,splash启动画面(改)

MFC,splash启动画面(改)

 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();//销毁初始画面窗口

 

完成

MFC,splash启动画面(改)