八宝书库 > 文学其他电子书 > 深入浅出MFC第2版(PDF格式) >

第159部分

深入浅出MFC第2版(PDF格式)-第159部分

小说: 深入浅出MFC第2版(PDF格式) 字数: 每页4000字

按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!




#0056                  pSubMenu…》CreatePopupMenu(); 

#0057                  pSubMenu…》InsertMenu(0; MF_STRING|MF_BYPOSITION; 

#0058                          CG_IDS_TIPOFTHEDAY; strTipMenu); 

#0059              } 

#0060              pMenu…》AppendMenu(MF_STRING|MF_BYPOSITION|MF_ENABLED|MF_POPUP; 



                                                                                                  807 


…………………………………………………………Page 870……………………………………………………………

                    第篇    深入  MFC  程式設計 



                    #0061                      (UINT)pSubMenu…》m_hMenu; strHelp); 

                    #0062              DrawMenuBar(); 

                    #0063          } 

                    #0064          else 

                    #0065          { 

                    #0066              // Check to see if the Tip of the Day menu has already been 

                    added。 

                    #0067              pSubMenu…》GetMenuString(0; strMenu; MF_BYPOSITION); 

                    #0068 

                    #0069              if (strMenu != strTipMenu) 

                    #0070              { 

                    #0071                  // Tip of the Day submenu has not been added to the 

                    #0072                  // first position; so add it。 

                    #0073                  pSubMenu…》InsertMenu(0; MF_BYPOSITION);  // Separator 

                    #0074                  pSubMenu…》InsertMenu(0; MF_STRING|MF_BYPOSITION; 

                    #0075                          CG_IDS_TIPOFTHEDAY; strTipMenu); 

                    #0076              } 

                    #0077          } 

                    #0078      } 

                    #0080  } 



                    SPLASH。H (全新內容 ) 



                    #0001  // CG: This file was added by the Splash Screen ponent。 

                    #0002 

                    #0003  #ifndef _SPLASH_SCRN_ 

                    #0004  #define _SPLASH_SCRN_ 

                    #0005 

                    #0006  // Splash。h : header file 

                    #0007 

                    #0008  ///////////////////////////////////////////////////////////////// 

                    #0009  //   Splash Screen class 

                    #0010 

                    #0011  class CSplashWnd : public CWnd 

                    #0012  { 

                    #0013  // Construction 

                    #0014  protected: 

                    #0015          CSplashWnd(); 

                    #0016 

                    #0017  // Attributes: 

                    #0018  public: 

                    #0019          CBitmap m_bitmap; 

                    #0020 

                    #0021  // Operations 

                    #0022  public: 

                    #0023          static void EnableSplashScreen(BOOL bEnable = TRUE); 



808 


…………………………………………………………Page 871……………………………………………………………

                            16                           ponents & ActiveX Controls 

                         第 章 站眾的肩膀 使用 



#0024          static void ShowSplashScreen(CWnd* pParentWnd = NULL); 

#0025          static BOOL PreTranslateAppMessage(MSG* pMsg); 

#0026 

#0027  // Overrides 

#0028          // ClassWizard generated virtual function overrides 

#0029          //{{AFX_VIRTUAL(CSplashWnd) 

#0030          //}}AFX_VIRTUAL 

#0031 

#0032  // Implementation 

#0033  public: 

#0034          ~CSplashWnd(); 

#0035          virtual void PostNcDestroy(); 

#0036 

#0037  protected: 

#0038          BOOL Create(CWnd* pParentWnd = NULL); 

#0039          void HideSplashScreen(); 

#0040          static BOOL c_bShowSplashWnd; 

#0041          static CSplashWnd* c_pSplashWnd; 

#0042 

#0043  // Generated message map functions 

#0044  protected: 

#0045          //{{AFX_MSG(CSplashWnd) 

#0046          afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 

#0047          afx_msg void OnPaint(); 

#0048          afx_msg void OnTimer(UINT nIDEvent); 

#0049          //}}AFX_MSG 

#0050          DECLARE_MESSAGE_MAP() 

#0051  }; 

#0052 

#0053  #endif 



SPLASH。CPP (全新內容 ) 



#0001  // CG: This file was added by the Splash Screen ponent。 

#0002  // Splash。cpp : implementation file 

#0003 

#0004  #include 〃stdafx。h〃  // e。 g。 stdafx。h 

#0005  #include 〃resource。h〃  // e。g。 resource。h 

#0006 

#0007  #include 〃Splash。h〃  // e。g。 splash。h 

#0008 

#0009  #ifdef _DEBUG 

#0010  #define new DEBUG_NEW 

#0011  #undef THIS_FILE 

#0012  static char BASED_CODE THIS_FILE'' = __FILE__; 

#0013  #endif 



                                                                                              809 


…………………………………………………………Page 872……………………………………………………………

                   第篇    深入  MFC  程式設計 



                   #0014 

                   #0015  ///////////////////////////////////////////////////////////////// 

                   #0016  //   Splash Screen class 

                   #0017 

                   #0018  BOOL CSplashWnd::c_bShowSplashWnd; 

                   #0019  CSplashWnd* CSplashWnd::c_pSplashWnd; 

                   #0020  CSplashWnd::CSplashWnd() 

                   #0021  { 

                   #0022  } 

                   #0023 

                   #0024  CSplashWnd::~CSplashWnd() 

                   #0025  { 

                   #0026          // Clear the static window pointer。 

                   #0027          ASSERT(c_pSplashWnd == this); 

                   #0028          c_pSplashWnd = NULL; 

                   #0029  } 

                   #0030 

                   #0031  BEGIN_MESSAGE_MAP(CSplashWnd; CWnd) 

                   #0032          //{{AFX_MSG_MAP(CSplashWnd) 

                   #0033          ON_WM_CREATE() 

                   #0034          ON_WM_PAINT() 

                   #0035          ON_WM_TIMER() 

                   #0036          //}}AFX_MSG_MAP 

                   #0037  END_MESSAGE_MAP() 

                   #0038 

                   #0039  void CSplashWnd::EnableSplashScreen(BOOL bEnable /*= TRUE*/) 

                   #0040  { 

                   #0041          c_bShowSplashWnd = bEnable; 

                   #0042  } 

                   #0043 

                   #0044  void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/) 

                   #0045  { 

                   #0046          if (!c_bShowSplashWnd || c_pSplashWnd != NULL) 

                   #0047                  return; 

                   #0048 

                   #0049          // Allocate a new splash screen; and create the window。 

                   #0050          c_pSplashWnd = new CSplashWnd; 

                   #0051          if (!c_pSplashWnd…》Create(pParentWnd)) 

                   #0052                  delete c_pSplashWnd; 

                   #0053          else 

                   #0054                  c_pSplashWnd…》UpdateWindow(); 

                   #0055  } 

                   #0056 

                   #0057  BOOL CSplashWnd::PreTranslateAppMessage(MSG* pMsg) 

                   #0058  { 

                   #0059          if (c_pSplashWnd == NULL) 



810 


…………………………………………………………Page 873……………………………………………………………

                             16                            ponents & ActiveX Controls 

                          第 章 站眾的肩膀 使用 



#0060                  return FALSE; 

#0061 

#0062          // If we get a keyboard or mouse message; hide the splash screen。 

#0063          if (pMsg…》message == WM_KEYDOWN || 

#0064              pMsg…》message == WM_SYSKEYDOWN || 

#0065              pMsg…》message == WM_LBUTTONDOWN || 

#0066              pMsg…》message == WM_RBUTTONDOWN || 

#0067              pMsg…》message == WM_MBUTTONDOWN || 

#0068              pMsg…》message == WM_NCLBUTTONDOWN || 

#0069              pMsg…》message == WM_NCRBUTTONDOWN || 

#0070              pMsg…》message == WM_NCMBUTTONDOWN) 

#0071          { 

#0072                  c_pSplashWnd…》HideSplashScreen(); 

#0073                  return TRUE;    // message handled here 

#0074          } 

#0075 

#0076          return FALSE;   // message not handled 

#0077  } 

#0078 

#0079  BOOL CSplashWnd::Create(CWnd* pParentWnd /*= NULL*/) 

#0080  { 

#0081      if (!m_bitmap。LoadBitmap(IDB_SPLASH)) 

#0082            return FALSE; 

#0083 

#0084      BITMAP bm; 

#0085      m_bitmap。GetBitmap(&bm); 

#0086 

#0087      return CreateEx(0; 

#0088              AfxRegisterWndClass(0; AfxGetApp()…》LoadStandardCursor(IDC_ARROW)); 

#0089              NULL; WS_POPUP | WS_VISIBLE; 0; 0; bm。bmWidth; bm。bmHeight; 

pParentWnd…》GetSafeHwnd(); NULL); 

#0090  } 

#0091 

#0092  void CSplashWnd::HideSplashScreen() 

#0093  { 

#0094          // Destroy the window; and update the mainframe。 

#0095          DestroyWindow(); 

#0096          AfxGetMainWnd()…》UpdateWindow(); 

#0097  } 

#0098 

#0099  void CSplashWnd::PostNcDestroy() 

#0100  { 

#0101          // Free the C++ class。 

#0102          delete this; 

#0103  } 

#0104 



                                                                                                 811 


…………………………………………………………Page 874……………………………………………………………

                   第篇    深入  MFC  程式設計 



                    #0105  int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 

                    #0106  { 

                    #0107          if (CWnd::OnCreate(lpCreateStruct) == …1) 

                    #0108                  return …1; 

                    #0109 

                    #0110          // Center the window。 

                    #0111          CenterWindow(); 

                    #0112 

                    #0113          // Set a timer to destroy the splash screen。 

                    #0114          SetTimer(1; 750; NULL); 

                    #0115 

                   

返回目录 上一页 下一页 回到顶部 0 0

你可能喜欢的