自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

VS2003模板的下載與使用和注意事項

開發(fā) 后端
我們新的VS2003模板,是一個很通用的數(shù)據(jù)庫管理程序,到目前為止所有的代碼都是通過VS編寫的,核心部分的設計基本完成,希望可以通過.NET開發(fā)一些小的模塊,VC8.0(Visual C++2005)。

本文講述VS2003模板的具體細節(jié),怎樣創(chuàng)建VS2003模板。這些內(nèi)容都是我這些天花了一周的時間查閱資料并像IT精英學習出來的,中間可能有不少的錯誤,歡迎大家指正。下面就說明下。

VS2003模板升級的基本過程如下:

1、首先備份現(xiàn)有的VC程序,備份之后啟動VS2005。

2、通過VS2005打開要升級的解決方案,系統(tǒng)提示自動轉換,如果VC程序已經(jīng)被嵌入到VSS中,則系統(tǒng)將提示登錄VSS,并且自動將解決方案文件和項目文件簽出。(注意選擇備份原來版本 的解決方案的選項。)

3、一般情況下系統(tǒng)提示成功,可能會有兩個警告,可以不予理會。因為升級過程中僅僅修改了解決方案文件和工程項目文件,所以速度會很快,C++頭文件和CPP文件都不作任何修改(這和VB6到VB2005的升級不同),因此速度很快。

4、在VS2005中重新編譯升級后的程序,很可能出現(xiàn)很多警告和錯誤提示,警告可以不予理會,錯誤提示必須修改。我所遇到的錯誤提示主要有兩種:一種提示是“某個變量沒有定義”,另外一種是模板類的消息映射的錯誤提示。

先說第一種錯誤提示,例如如下的兩個for循環(huán)語句

  1. for(int i=0;i<10;i++)  
  2. {  
  3. }  
  4. for(i=0;i<100;i++)//此處將提示i沒有定義  

上面的語句在VS2003中沒有問題,在2005中則是錯誤的,2005將i作為第一個for循環(huán)中的局部變量處理,因此編譯器認為第二個for循環(huán)中的i沒有定義。這類錯誤可能有很多,但是修改起來比較容易。

VS2003模板第二種錯誤是模板類的消息映射宏錯誤。我在程序中設計了一個控件模板:

  1. template <class B,class P>class CUniDataCtrl : public B,public CUniDataBaseCtrl  #t#

則直接實現(xiàn)了原來幾十行代碼實現(xiàn)的功能。

上述的模板類消息映射宏我是參考BEGIN_TEMPLATE_MESSAGE_MAP(theClass, type_name, baseClass)編寫的,該宏只支持一個模板參數(shù),而我定義的模板中需要兩個模板參數(shù),因此,我自己擴充了一下VS2003模板的內(nèi)容。關于BEGIN_TEMPLATE_MESSAGE_MAP的幫助在MSDN中好像沒有,在afxwin.h中定義了:

  1. #define BEGIN_TEMPLATE_MESSAGE_MAP_EX(theClass, type_name1,type_name2,  baseClass)     
  2.  PTM_WARNING_DISABLE                
  3.  template < typename type_name1,typename type_name2 >             
  4.  const AFX_MSGMP* theClass< type_name1 ,type_name2 >::GetMessageMap() const     
  5.   { return GetThisMessageMap(); }            
  6.  template < typename type_name1 ,typename type_name2>             
  7.  const AFX_MSGMAP* PASCAL theClass< type_name1 ,type_name2  >::GetThisMessageMap()    
  8.  {                    
  9.   typedef theClass< type_name1 ,type_name2  > ThisClass;         
  10.   typedef baseClass TheBaseClass;            
  11.   static const AFX_MSGMAP_ENTRY _messageEntries[] =    
  12.   {  
  13.  
  14. BEGIN_TEMPLATE_MESSAGE_MAP_EX(CUniDataCtrl,B,P ,B)  
  15.  ON_WM_LBUTTONDOWN()  
  16.  ON_WM_RBUTTO  
  17.  
  18. #define DECLARE_MESSAGE_MAP()   
  19. protected:   
  20.  static const AFX_MSGMAP* PASCAL GetThisMessageMap();   
  21.  virtual const AFX_MSGMAP* GetMessageMap() const;   
  22.  
  23. #define BEGIN_TEMPLATE_MESSAGE_MAP(theClass, type_name, baseClass)     
  24.  PTM_WARNING_DISABLE                
  25.  template < typename type_name >             
  26.  const AFX_MSGMAP* theClass< type_name >::GetMessageMap() const     
  27.   { return GetThisMessageMap(); }            
  28.  template < typename type_name >             
  29.  const AFX_MSGMAP* PASCAL theClass< type_name >::GetThisMessageMap()    
  30.  {                    
  31.   typedef theClass< type_name > ThisClass;         
  32.   typedef baseClass TheBaseClass;            
  33.   static const AFX_MSGMAP_ENTRY _messageEntries[] =       
  34.   {  
  35. #define BEGIN_MESSAGE_MAP(theClass, baseClass)   
  36.  PTM_WARNING_DISABLE   
  37.  const AFX_MSGMAP* theClass::GetMessageMap() const   
  38.   { return GetThisMessageMap(); }   
  39.  const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap()   
  40.  {   
  41.   typedef theClass ThisClass;           
  42.   typedef baseClass TheBaseClass;  
  43.   static const AFX_MSGMAP_ENTRY _messageEntries[] =    
  44.   {  
  45. #define END_MESSAGE_MAP()   
  46.   {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 }   
  47.  };   
  48.   static const AFX_MSGMAP messageMap =   
  49.   { &TheBaseClass::GetThisMessageMap, &_messageEntries[0] };   
  50.   return &messageMap;  
  51.  }     
  52.  PTM_WARNING_RESTORE  

 

責任編輯:chenqingxiang 來源: 許諾
相關推薦

2009-11-26 10:35:16

VS2003制作安裝

2009-12-01 11:21:25

VS2003 報表

2009-12-10 09:50:49

VS.NET 2003

2009-11-27 09:53:15

VS2003安裝程序

2009-11-25 13:35:05

VS2003使用

2009-11-30 11:14:57

VS2003 WebS

2009-11-26 09:42:38

VS2003插件

2009-11-30 09:27:38

VS2003源代碼

2009-11-26 11:30:12

VS2003控件

2009-12-01 16:32:20

VS2003安裝步驟

2009-11-27 14:25:57

VS2003模板

2009-11-30 11:05:19

VS2003 WebS

2009-11-30 17:28:39

VS2003 ASP

2009-11-27 10:14:44

2009-12-15 10:10:38

VS 2008開發(fā)

2009-11-26 10:02:06

2009-11-26 13:05:39

VS2003斷點

2009-11-30 09:16:44

VS2003源代碼

2009-11-30 10:34:28

VS2003編譯

2009-12-11 14:38:06

VS2003安裝程序
點贊
收藏

51CTO技術棧公眾號