wince的CSplashWnd

来源:互联网 发布:python自动化股票交易 编辑:程序博客网 时间:2024/06/16 11:45
  1. ///////////////////////////////////////////////////////////////   
  2.  // splashwnd.h   
  3.     
  4.   #if   !defined(AFX_SPLASHWND_H__24A0BA9F_A099_4AE2_81AE_76599D2DC19E__INCLUDED_)   
  5.   #define   AFX_SPLASHWND_H__24A0BA9F_A099_4AE2_81AE_76599D2DC19E__INCLUDED_   
  6.     
  7.   #if   _MSC_VER   >=   1000   
  8.   #pragma   once   
  9.   #endif   //   _MSC_VER   >=   1000   
  10.   //   splashwnd.h   :   header   file   
  11.   //   
  12.     
  13.   /////////////////////////////////////////////////////////////////////////////   
  14.   //   CSplashWnd   window   
  15.     
  16.   class   CSplashWnd   :   public   CWnd   
  17.   {   
  18.   //   Construction   
  19.   public:   
  20.   CSplashWnd();   
  21.     
  22.   //   Attributes   
  23.   private:   
  24.   CBitmap   m_bitmap;   
  25.   //   Operations   
  26.   public:   
  27.     
  28.   //   Overrides   
  29.   //   ClassWizard   generated   virtual   function   overrides   
  30.   //{{AFX_VIRTUAL(CSplashWnd)   
  31.   //}}AFX_VIRTUAL   
  32.     
  33.   //   Implementation   
  34.   public:   
  35.   static   void   ShowSplashScreen(CWnd*   pParentWnd   =   NULL);   
  36.   virtual   ~CSplashWnd();   
  37.     
  38.   //   Generated   message   map   functions   
  39.   protected:   
  40.   BOOL   Create(CWnd*   pParentWnd   =   NULL);   
  41.   void   HideSplashScreen();   
  42.   static   CSplashWnd*   c_pSplashWnd;   
  43.   //{{AFX_MSG(CSplashWnd)   
  44.   afx_msg   void   OnPaint();   
  45.   afx_msg   void   OnTimer(UINT   nIDEvent);   
  46.   afx_msg   int   OnCreate(LPCREATESTRUCT   lpCreateStruct);   
  47.   //}}AFX_MSG   
  48.   DECLARE_MESSAGE_MAP()   
  49.   private:   
  50.   void   PostNcDestroy();   
  51.   };   
  52.     
  53.   /////////////////////////////////////////////////////////////////////////////   
  54.     
  55.   //{{AFX_INSERT_LOCATION}}   
  56.   //   Microsoft   Visual   C++   will   insert   additional   declarations   immediately   before   the   previous   line.   
  57.     
  58.   #endif   //   !defined(AFX_SPLASHWND_H__24A0BA9F_A099_4AE2_81AE_76599D2DC19E__INCLUDED_)   
  59.     

 论坛上某位兄弟移植的,刚刚用了,挺不错,共享一下

 

  1.   //   splashwnd.cpp   :   implementation   file   
  2.   //   
  3.   #include   "stdafx.h"   
  4.   #include   "resource.h"   
  5.   #include   "splashwnd.h"   
  6.     
  7.   #ifdef   _DEBUG   
  8.   #define   new   DEBUG_NEW   
  9.   #undef   THIS_FILE   
  10.   static   char   THIS_FILE[]   =   __FILE__;   
  11.   #endif   
  12.     
  13.   /////////////////////////////////////////////////////////////////////////////   
  14.   //   CSplashWnd   
  15.   //BOOL   CSplashWnd::c_bShowSplashWnd;   
  16.   CSplashWnd*   CSplashWnd::c_pSplashWnd;   
  17.   CSplashWnd::CSplashWnd()   
  18.   {   
  19.   }   
  20.     
  21.   CSplashWnd::~CSplashWnd()   
  22.   {   
  23.   ASSERT(c_pSplashWnd   ==   this);   
  24.   c_pSplashWnd   =   NULL;   
  25.   }   
  26.     
  27.   BEGIN_MESSAGE_MAP(CSplashWnd,   CWnd)   
  28.   //{{AFX_MSG_MAP(CSplashWnd)   
  29.   ON_WM_PAINT()   
  30.   ON_WM_TIMER()   
  31.   ON_WM_CREATE()   
  32.   //}}AFX_MSG_MAP   
  33.   END_MESSAGE_MAP()   
  34.     
  35.     
  36.   /////////////////////////////////////////////////////////////////////////////   
  37.   //   CSplashWnd   message   handlers   
  38.     
  39.   void   CSplashWnd::OnPaint()     
  40.   {   
  41.   CPaintDC   dc(this);   
  42.     
  43.   CDC   dcImage;   
  44.   if   (!dcImage.CreateCompatibleDC(&dc))   
  45.   return;   
  46.     
  47.   BITMAP   bm;   
  48.   m_bitmap.GetBitmap(&bm);   
  49.     
  50.   //   Paint   the   image.   
  51.   CBitmap*   pOldBitmap   =   dcImage.SelectObject(&m_bitmap);   
  52.   dc.BitBlt(0,   0,   bm.bmWidth,   bm.bmHeight,   &dcImage,   0,   0,   SRCCOPY);   
  53.   dcImage.SelectObject(pOldBitmap);   
  54.   }   
  55.     
  56.   void   CSplashWnd::OnTimer(UINT   nIDEvent)     
  57.   {   
  58.   //   Destroy   the   splash   screen   window.   
  59.   HideSplashScreen();   
  60.   }   
  61.     
  62.   int   CSplashWnd::OnCreate(LPCREATESTRUCT   lpCreateStruct)     
  63.   {   
  64.   if   (CWnd::OnCreate(lpCreateStruct)   ==   -1)   
  65.   return   -1;   
  66.     
  67.   //   Center   the   window.   
  68.   CenterWindow();   
  69.     
  70.   //   Set   a   timer   to   destroy   the   splash   screen.   
  71.   SetTimer(1,   10000,   NULL);   
  72.     
  73.   return   0;   
  74.   }   
  75.     
  76.   void   CSplashWnd::ShowSplashScreen(CWnd*   pParentWnd   /*=   NULL*/)   
  77.   {   
  78.   if   (/*!c_bShowSplashWnd   ||   */c_pSplashWnd   !=   NULL)   
  79.   return;   
  80.     
  81.   //   Allocate   a   new   splash   screen,   and   create   the   window.   
  82.   c_pSplashWnd   =   new   CSplashWnd;   
  83.   if   (!c_pSplashWnd->Create(pParentWnd))   
  84.   delete   c_pSplashWnd;   
  85.   else   
  86.   c_pSplashWnd->UpdateWindow();   
  87.   }   
  88.     
  89.   void   CSplashWnd::HideSplashScreen()   
  90.   {   
  91.   //   Destroy   the   window,   and   update   the   mainframe.   
  92.   DestroyWindow();   
  93.   AfxGetMainWnd()->UpdateWindow();   
  94.   }   
  95.     
  96.   BOOL   CSplashWnd::Create(CWnd*   pParentWnd   /*=   NULL*/)   
  97.   {   
  98.   if   (!m_bitmap.LoadBitmap(IDB_START))   
  99.   return   FALSE;   
  100.     
  101.   BITMAP   bm;   
  102.   m_bitmap.GetBitmap(&bm);   
  103.     
  104.   return   CreateEx(0,   
  105.   AfxRegisterWndClass(0,   AfxGetApp()->LoadStandardCursor(IDC_ARROW)),   
  106.   NULL,   WS_POPUP   |   WS_VISIBLE,   0,   0,   bm.bmWidth,   bm.bmHeight,   pParentWnd->GetSafeHwnd(),   NULL);   
  107.   }   
  108.     
  109.   void   CSplashWnd::PostNcDestroy()   
  110.   {   
  111.   //   Free   the   C++   class.   
  112.   delete   this;   
  113.   }
原创粉丝点击