VC++6.0中的部分类的新特性   VC6.0比起VC5.0来,界面与其各自提供的MFC类都有所不同。例如,VC6.0中没有了5.0版本中Workspace的InfoView,其相关内容另外提供在MSDN 中;再如,用MFC AppWizard(exe)生成Document 的过程中,你可以选择你的项目是标准型(MFC Standard)还是浏览器型(Windows Explorer)等等。这些都是较为明显且很容易看到并能运用的。其实我觉得其中较为隐蔽也最重要的是其MFC 类版本的提高所提供的更多的类、更多的函数、更多的结构。能否运用这些“更多”来开发手中的产品,是你的产品是否跟得上比尔他老人家Windows的关键。   例如,CPropertyPage与CPropertySheet大家一定很熟悉吧,但若要你在向导页上加背景图像、标题图像可不一定容易。用VC6.0中提供的CPropertyPageEx与CPropertySheetEx可以很容易地办到。下面一起来做一个看看。     准备尺寸为320×240,320×80的两张24位(确信你的系统支持) .BMP;   运行VC6.0,File>New>Projectx>MFC AppWizard(exe),在Project Name中填写:NewWizard; 单击OK,选Dialog based,Next,不选About box,Finish。在生成的项目中删除ID为IDD_NEWWIZARD_DIALOG的Dialog以及NewWizardDlg.h、NewWizardDlg.cpp两个文件。   然后是Insert>New Class...,Name填CNWPropertySheet,Base class选CPropertySheet(不会自动提供CPropertySheetEx与CPropertyPageEx,怎么办?等一下自己改);   打开NewWizard.cpp文件,把 #include “NewWizardDlg.h"改为#include“NWPropertySheet.h"; InitInstance 函数改为:    BOOL CNewWizardApp::InitInstance()    {    AfxEnableControlContainer();    #ifdef _AFXDLL    Enable3dControls();    #else    Enable3dControlsStatic();    #endif    CBitmap hbmWatermark;    CBitmap hbmHeader;    hbmWatermark.LoadBitmap(IDB_WATERMARK); hbmHeader.LoadBitmap(IDB_HEADER);    CNWPropertySheet dlg(_T(“New Wizard"), NULL, 0,hbmWatermark, NULL, hbmHeader);   m_pMainWnd = &dlg; // 不用dlg.SetWizardMode();    int nResponse = dlg.DoModal();    if (nResponse == IDOK)    {    }    else if (nResponse == IDCANCEL)    {    }    return FALSE;    }    记得把两个.BMP文件加入(Insert>Import...)。ID值分别为IDB_WATERMARK、IDB_HEADER(在VC6.0中不可以打开24位.BMP,但可以点右键改ID)。     接下来新建两个Dialog,去掉OK与CANCEL两按钮。利用ClassWizard分别生成基于它们的NewClass:CPage1,CPage2;Base class都为CPropertyPage。利用ClassWizard为它们加入OnSetActive();打开Page1.cpp文件,在OnSetActive()中加入:   CPropertySheet* pSheet = (CPropertySheet*)GetParent();   ASSERT_KINDOF(CPropertySheet, pSheet);   pSheet->SetWizardButtons(PSWIZB_NEXT);     为了在首页Page1呈现水印(watermark),即第一幅.BMP,还需在解析函数中加入m_psp.dwFlags |=PSP_HIDEHEADER; 同样,在Page2.cpp 文件的OnSetActive() 中加入   CPropertySheet* pSheet = (CPropertySheet*)GetParent();    ASSERT_KINDOF(CPropertySheet, pSheet);    pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_FINISH);    打开NWPropertySheet.h , 在其开头处加入    #include “Page1.h" #include “Page2.h" CNWPropertySheet 类中说明:    public:    CPage1 pPage1;    CPage2 pPage2;    接着打开 NWPropertySheet.cpp , 需在解析函数(两个)中加入:    AddPage(&pPage1);    AddPage(&pPage2);    m_psh.dwFlags |= PSH_WIZARD97; // 新特性     好了,接下来要做的就是手工把CPropertySheet与CPropertyPage改为CPropertySheetEx与CPropertyPageEx。可以利用Edit>Replace,一个一个文件改。但是,它们的结构都不同(CPropertySheetEx 在CPropertySheet上扩展),例如,CNWPropertySheet类中应为:   public:    CNWPropertySheet(UINT nIDCaption, CWnd*pParentWnd=NULL, UINT iSelectPage=0,HBITMAP hbmWatermark=NULL,HPALETTE hpalWatermark=NULL,HBITMAP hbmHeader=NULL);  CNWPropertySheet(LPCTSTR pszCaption,CWnd*pParentWnd=NULL,UINT iSelectPage=0,HBITMAP hbmWatermark=NULL,HPALETTE hpalWatermark=NULL,HBITMAP hbmHeader=NULL);   在其.CPP中也应做相应改变:    CNWPropertySheet::CNWPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage, HBITMAP hbmWatermark, HPALETTE hpalWatermark,HBITMAP hbmHeader)    :CPropertySheet(nIDCaption, pParentWnd, iSelectPage,hbmWatermark, hpalWatermark, hbmHeader)    {    AddPage(&pPage1);   ……    CNWPropertySheet::CNWPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage,    HBITMAP hbmWatermark, HPALETTE hpalWatermark,HBITMAP hbmHeader)    :CPropertySheetEx(pszCaption, pParentWnd, iSelectPage,hbmWatermark, hpalWatermark, hbmHeader)   {    AddPage(&pPage1);   ……   都改好了吗?如果可以了就编译运行,看一看新的向导是什么样。其实,好不好看就取决与你的BMP 了。     总结:   1.ClassWizard中不提供CPropertySheetEx及CPropertyPageEx,需要动手改,改的时候不要漏掉任何地方(Edit>Replace...中的Replace All 只改当前文件);     2.确信你的系统支持24位BMP,如果不支持,可用256色代替;   3.以上例子要求Windows 98 或Windows NT5.0(即Windows 2000)操作系统和Visual C++6.0。     其实,VC6.0提供的远多于这些,还有好多新的先进的技术。