        

         ,      
   ,  .  ,  
     ,  
      .  ,  
  ,      . 
 ,        " , 
 ,  ...'. ,       
 ,   . ,  Windows 95   
     ,     . 
             , 
  .        
  ,    .    
   ,    , 
   . 

    329 


                 | 

             
,       . , 
,         
  .      . 13.1.  
,          .  
    ,     
 .       , 
   12.          
     . 

    . 13.1.    

              
  ,       , 
    .   ,      
   (,  ,     
    ). 

    330                                    MFC:   

     MFC       CPropertySheet,  
    CWnd.     
  CPropertyPage,    CDialog. 
            :   Cancel.  
     Apply.  , ,    
        
  ,     (,  ) 
 ,      ,  
.   ,        
  OK, Cancel  Apply.       
   . 
           .   
        .  
,         , 
..      .  ,   
    ,     . 
  -      
  CPropertyPage.      . 
             
:   CPropertyPage,    ,   
   . ..       
EndDialogO,   DestroyWindowO.     
  .       ,   
  ,    . ,  
    . 
               
  AFXDLGS.H. 

       

              
:    CPropertySheet,       
 CPropertyPage.    CPropertyPage    
  .     (  
  )     .  
     . 
      ,   ,   
CPropertySheet  CPropertyPage   .    
   .       
  CPropertyPage   ,    
. ,   CPropertySheet,     
  ,   . 
             
   .    : 
             ; 
            ,   
 . 

    73.     331 

          . 

        

    ,   ,      . 
  CPropertyPage    CDialog,   
     .  ,  
  ,       
    CPropertyPage,    CDialog. 
 CPropertyPage    : 

    CPropertyPage () ; 
    CPropertyPage (LPCSTR Name, UINT 1>=0) ; 
    CPropertyPage(HINT ID, UINT TabID^O}; 

          ,   
 .     Name    
    .      ID 
    .     
TabID    ,     
     .     
,          . 
      CPropertyPageQ    (..  
 ),       
  Construct(),     : 

    void CPropertyPage::Construct(LPCSTR Name, UINT TabID=0); 
    void CPropertyPage::Construct(UINT ID, UINT TabID=0); 

      Name        
.  ID    .   
  TabID    ,   
       .   
  ,         
 . 
      ,        
   ,   CPropertyPage  
 .         
   ,      CDialog.  
,  ,   CPropertyPage,    
      . 

        

      ,  , ,    
     .      
CPropertySheet.       
    : 

    CPropertySheet () ; 
    CPropertySheet(UINT TitleID, CWnd *0^ner=NULL, UINT Page=0) ; 
    CPropertySheet(LPCSTR IpszTitle, CWnd *Owner=NULL, UINT Page=0); 


    332 MFC:   

           .  
   TitleID     
 .     Ips^Title    
 .     Owner     
    ,   Page    , 
      .     . 
      CPropertySheetO    (..  
   ),      
   Construct(),     : 

    void CPropertySheet::Construct(DINT TitleID, CWnd *Owner=NULL, 
    UINT Page=0) ; 
    void CPropertySheet::Construct(LPCSTR IpszTitle, CWnd *Owner=NULL, 
    UINT Page=0) ; 

     TitleID      . 
 IpszTitle       .   
  Owner        
 ,   Page    ,   . 

         

         ,     
.      AddPageQ,    
CPropertySheet.    : 

    void CPropertySheet::AddPage(CPropertyPage * }; 

     Page       CPropertyPage,  
  ,   CPropertyPage. 
          .  ,  
      . 

       

            ,   
    DoModalQ.     
    .  DoModalQ   : 

    virtual int CPropertySheet::DoModal(); 

       IDOK,  IDCANCEL.    
 .         , 
    .      
    Cancel. 
            
Create()  CPropertySheet.       
 .      ,    
. ,    ,    
CPropertySheet, ,     . (, 
   

    13.     333 

      OK, Cancel  Apply   .)   
       . 

        

        ,     
    : 
    1.           . 
    2.   CPropertyPage      , 
 . 
    3.   CPropertySheet    ,   
.        . 
    4.    ,   CPropertySheet 
    5.        DoModalQ. 
             . 

     ,     

        ,  ,    
  . ,     
  WM_INn DIALOG,     
 OnInitDialogO      CPropertyPage   
  ,    .    
 (. 13.1): 

     13. I. ,     

              

    1()              Apply 
    OnCancelQ             Cancel 
    OnKillActiveQ             
    ()                 
    OnResctQ              Cancel 
    OnSetActiveQ             ( ) 

        : 

    virtual void CPropertyPage OnApplyO; 
    virtual void CPropertyPage OnCancelO; 
    virtual void CPropertyPage OnKillActive(); 
    virtual void CPropertyPage OnOK(); 
    virtual void CPropertyPage OnResetO; 
    virtual void CPropertyPage OnSetActive(); 


    334                                    MFC:   

    ,   CPropertyPage,     
   ,    . ,  
  ()     ,  
,  .    OnResetQ  
     .    
OnApplyQ ,     ,   
,        . 

      Apply 

          Apply .  
 ,    SetModifiedQ,   
 : 

    void CPropertyPage::SetModified(BOOL How=TRVE); 

      How ,    Apply    
, , .      ,    
.      . 
     SetModified()    ,   
 -    . 

         

           ,  
 .         
 ,         
   . 
        : 

    ;       
    tinclude <afxres.h> 
    #include "ids.h" 
    PropertyMenu MENU 
    ( 
    POPUP "&Property Sheet" 
    { 
    
    MENUITEM "&Activate\tF2", IDM_ACTIVATE 
    MENUITEM "E&xit\tF3", IDM_EXIT 
    ) 
    
    MENUITEM "&Help", IDM_HELP 
    } 
    PropertyMenu ACCELERATORS 
    ( 
    
    VK_F2, IDM_ACTIVATE, VIRTKEY 
    VK_F3, IDM_EXIT, VIRTKEY 


    13.                                               335 


    VK_F1, IDM_HELP, VIRTKEY ) 
    PropDialogI DIALOG 10, 10, 110, 100 
    Caption "First Page" 
    STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU I WS_VISIBLE 
    ( 
    DEFPUSHBUTTON "One", IDDJ3NE, 11, 10, 32, 14, 
    
    WS_CHILD [ WS_VISIBLE | WS_TABSTOP 
    PUSHBUTTON "Two", IDD_TWO, 11, 34, 32, 14, 
    
    WS_CHILD I WS_VISIBLE | WS_TABSTOP 
    PUSHBUTTON "Three", IDD_THREE, 11, 58, 32, 14, 
    
    WS_CHILD I WS_VISIBLE | WS_TABSTOP 
    LISTBOX IDD_LB1, 66, 25, 50, 33, LBS_NOTIFY | 
    
    WS_VISIBLE | WS_BORDER | WS__VSCROLL | WS_TABSTOP 
    ) 
    PropDialog2 DIALOG 10, 10, 110, 100 
    Caption "Second Page" 
    STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU I WS_VISIBLE 
    { 
    DEFPUSHBUTTON "Invert", IDD_INVERT, 11, 10, 32, 14, 
    
    WS_CHILD | WS_VISIBLE | WS_TABSTOP 
    AUTOCHECKBOX "Check Box I", IDD_CB1, 66, 10, 70, 10 
    AUTOCHECKBOX "Check Box 2", IDD_CB2, 66, 30, 70, 10 
    AUTOCHECKBOX "Check Box 3", IDD_CB3, 66, 50, 70, 10 
    } 
    PropDialog3 DIALOG 10, 10, , 100 
    Caption "Third Page" 
    STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU I WS_VISIBLE 
    ( 
    DEFPUSHBUTTON "Top", IDD_TOP, 11, 10, 32, 14, 
    
    WS_CHILD I WS_VISIBLE | WS_TABSTOP 
    PUSHBUTTON "Bottom", IDD_BOTTOM, 11, 34, 32, 14, 
    
    WS_CHILD I WS_VISIBLE | WS_TABSTOP 
    AUTORADIOBUTTON "Radio Button I", IDD_RB1, 66, 10, 70, 10 
    AUTORADIOBUTTON "Radio Button 2", IDD_RB2, 66, 30, 70, 10 
    AUTORADIOBUTTON "Radio Button 3", IDD_RB3, 66, 50, 70, 10 
    } 
         IDS.H: 
    #define IDM_ACTIVATE  100 
    #define IDM_EXIT      101 
    #define IDM_HELP      102 
    #define IDD_ONE       200 
    #define IDD_TWO       201 
    #define IDD_THREE     202 
    #define IDD_TOP       203 
    #define IDD_BOTTOM    204 


    336                                     MFC:   


    tdefine IDD_INVERT   205 
    tdefine IDD_LB1      301 
    tdefine IDD_CB1      501 
    #define IDD_CB2      502 
    tdefine IDD_CB3      503 
    tdefine IDD_RB1      601 
    tdefine IDD_RB2      602 
    #define IDD_RB3      603 
    #define NUMSTRINGS      5 
    tdefine NUMPAGES        3 
       PROP.H,    : 
    // PROP.H 
    /* 
      ,      
  .        
   
    #/ 
    //         
    class CPropDialogI : public CPropertyPage 
    { 
    public: 
    CPropDialogI () : CPropertyPage() (}; 
    BOOL OnInitDialog (); 
    BOOL OnApplyO ; 
    
    /*      
     : 
    
    void OnCancelO; //     Cancel 
    void OnOK(); //      
    #/ 
    afx msg void OnOneO; 
    afx msg void OnTwoO," 
    afx_msg void OnThree(); 
    afx_msg void OnListBoxO; 
    DECLARE_MESSAGE_MAP() 
    ); 
    //         
    class CPropDialog2 : public CPropertyPage 


    13.                                               337 


    public:                                                             
    CPropDialog2() : CPropertyPage {);                               I 
    BOOL OnInitDialog(); 
    BOOL OnApplyO ; 
    
    /*      
     : 
    
    void OnCancel (); //     Cancel 
    void OnOK(); //      
    */ 
    afx msg void Onlnvert(); 
    afx msg void OnCBlO; 
    afx_msg void OnCB2(); 
    afx_msg void ; 
    DECLARE_MESSAGE_MAP() 
    ); 
    
    //         
    class CPropDialog3 : public CPropertyPage 
    < 
    public: 
    CPropDialog3 () : CPropertyPage() (}; 
    BOOL OnInitDialog(); 
    BOOL OnApplyO ; 
    
    /*      
     : 
    
    void OnCancel(); //     Cancel 
    void OnOK(); //      
    */ 
    afx_msg void OnTopO; 
    afx msg void OnBottomO; 
    afx_msg void OnRBl(); 
    afx_msg void OnRB2(); 
    afx msg void OnRB3(); 
    DECLARE_MESSAGE_MAP() 
    }; 
    //       
    class CSamplePropSheet : public CPropertySheet 
    { 
    CPropDialogI pagel; //   


    338                                     MFC:   


    CPropDialog2 page2; //   
    CPropDialog3 ; //   
    public: 
    
    CSamplePropSheet() : CPropertySheet<) ( 
    Construct("Sample Property Sheet", this); 
    pagel.Construct("PropDialogI", 0) ; 
    pagel.Construct("PropDialog2" , 0) ; 
    pagel.Construct("PropDialog3", 0) ; 
    AddPage(&pagel) ; 
    AddPage(&page2) ; 
    AddPage(&page3) ; 
    } ); 
    //       
    class CMainWin : public CFrameWnd 
    { 
    
    CSamplePropSheet m PropSheet; //    
    public: 
    CMainWin() ; 
    afx msg void OnActivate (); 
    afx msg void OnExitO; 
    afx msg void OnHelpO; 
    DECLARE_MESSAGE_MAP() 
    ); 
    //      
    class'  : public CWinApp 
    ( 
    public: 
    BOOL Initlnstance () ; 
    ); 
       : 
    //    
    #include <afxwin.h> 
    #include <afxdlgs.h> 
    ^include <string.h> 
    #include "ids.h" 
    #include "prop.h" 
    char list[][40] = ( 
    "Red", 
    "Green", 
    "Yellow", 
    "Black", 
    "White", 
    }; 
    //     


    13.                                                339 


    CMainWin::CMainWin()                                                ' 
    { 
    Create(NULL, "Using A Property Sheet", 
    WS_OVERLAPPEDWINDOW, rectDefault, 
    NULL, "PropertyMenu"); 
    InitCommonControls () ; 
    
    //     
    if(!LoadAccelTable("PropertyMenu")) 
    MessageBox("Cannot Load Accelerators", "Error"); 
    
    //   
    BOOL CApp::Initlnstance() 
    ( 
    m pMainWnd = new CMainWin; 
    m_pMainWnd->ShowWindow(m_nCmdShow) ; 
    m_pMainWnd->UpdateWindow<) ; 
    return TRUE; 
    } 
    
    //                                      , 
    BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd)                                I 
    ON_COMMAND(IDM_ACTIVATE, OnActivate)                                ! 
    ON_COMMAND(IDM_EXIT, OnExit) 
    
    ON_COMMAND(IDM_HELP, OnHelp) 
    END_MESSAGE_MAP() 
    
    //   IDM_ACTIVATE 
    afx_msg void CMainWin::OnActivate() 
    ( 
    
    m_PropSheet.DoModal(); //     
    } 
    
    //   IDM_EXIT 
    afx_msg void CMainWin::OnExit() 
    { 
    int response; 
    response = MessageBox("Quit the Program?", "Exit", MB_YESNO) ; 
    if(response == IDYES) 
    SendMessage(WM CLOSE); //   1 
    
    //   IDM_HELP 
    afx_msg void CMainWin::OnHelp () 
    ( 
    MessageBox("Property Sheet", "Help"); 
    } 


    340                                    MFC:   


    //        
    BEGIN_MESSAGE_MAP(CPropDialogI, CPropertyPage) 
    ON_COMMAND(IDD_ONE, OnOne) 
    ON_COMMAND(IDD_TWO, OnTwo) 
    ON_COMMAND(IDD__THREE, OnThree) 
    
    ON_LBN_DBLCLK(IDD_LB1, OnListBox) 
    END_MESSAGE_MAP() 
    //      
    BOOL CPropDialogI::OnInitDialog() 
    ( 
    int i; 
    
    CPropertyPage::OnInitDialog(); //     
    CListBox *lbptr = (CListBox *) GetDlgItem(IDD_LB1) ; 
    
    for(i=0; i<NUMSTRINGS; i++) 
    lbptr->AddString(list[i]) ; 
    !bptr->SetCurSel(0) ; 
    return TRUE; 
    ) 
    
    //   OnApplyO  CPropDialogI 
    afx_msg BOOL CPropDialogI::OnApply() 
    ( 
    MessageBox("Selection Applied", "First Page"); 
    return TRUE; 
    1 
    
    //   IDD_ONE 
    afx_msg void CPropDialogI::0n0ne() 
    ( 
    MessageBox("One", "Button Pressed"); 
    ) 
    
    //   IDD TWO 
    arx msg void CPropDialogI::OnTwo() 
    { 
    MessageBox ("Two", "Button Pressed"); 
    ) 
    
    //   IDD_THREE 
    afx_msg void CPropDialogI::OnThree() 
    ( 
    MessageBox ("Three", "Button Pressed"); 
     
    //     
    afx_msg void CPropDialogI::OnListBox() 
    ( 
    int i; 


    13.                                               341 


    char str[255] ; 
    CListBox *lbptr = (CListBox *) GetDlgItem(IDD_LB1) ; 
    i = !bptr->GetCurSel (); 
    lbptr->GetText(i, str) ; 
    MessageBox(str, "Selection is"); 
    SetModified(l); 
    } 
    
    //        
    BEGIN_MESSAGE_MAP(CPropDialog2, CPropertyPage) 
    ON_COMMAND(IDD_INVERT, Onlnvert) 
    ON_COMMAND(IDD_CB1, OnCBl) 
    ON_COMMAND(IDD_CB2, OnCB2) 
    
    ON_COMMAND(IDD_CB3, ) 
    END_MESSAGE_MAP() 
    
    //                        J 
    BOOL CPropDialog2::OnInitDialog()                                   1 
    { 
    CPropertyPage::OnInitDialog(); //     
    CButton *cbptr = (CButton *) GetDlgItem(IDD_CB1); 
    cbptr->SetCheck(l);                                                i 
    return TRUE; 
    > 
    //   OnApplyO  CPropDialog2 
    afx_msg BOOL CPropDialog2::OnApply() 
    { 
    MessageBox("Selection Applied", "Second Page"); 
    return TRUE; 
     
    
    //   IDD_INVERT 
    afx_msg void CPropDialog2::Onlnvert() 
    { 
    CButton *lbptrl = (CButton *) GetDlgItem(IDD_CB1) ; 
    CButton *lbptr2 = (CButton *) GetDlgItem(IDD_CB2); 
    CButton *lbptr3 = (CButton *) GetDlgItem(IDD_CB3) ; 
    
    //     
    if(lbptrl->GetCheck()) lbptrl->SetCheck(0) ; 
    else lbptrl->SetCheck(l); 
    if(lbptr2->GetCheck()) lbptr2->SetCheck(0) ; 
    else lbptr2->SetCheck(l) ; 


    342                                     MFC:   


    if(lbptr3->GetCheck()) lbptr3->SetCheck(0) ; 
    else lbptr3->SetCheck(l); 
    SetModified(l) ; 
    1 
    
    //   IDD_CB1 
    afx_msg void CPropDialog2::OnCBl() 
    ( 
    SetModified(l) ; 
    ) 
    
    //   IDD_CB2 
    afx_nisg void CPropDialog2 : :OnCB2 () 
    ( 
    SetModified(l) ; 
    ) 
    
    //   IDD CB3 
    afx_msg void CPropDialog2::OnCB3() 
    ( 
    SetModified(1) ; 
    ) 
    
    //        
    BEGIN_MESSAGE_MAP(CPropDialog3, CPropertyPage) 
    ON_COMMAND(IDD_TOP, OnTop) 
    ON_COMMAND(IDD_BOTTOM, OnBottom) 
    ON_COMMAND(IDD_RB1, OnRBl) 
    ON_COMMAND(IDD_RB2, OnRB2) 
    
    ON_COMMAND(IDD_RB3, OnRB3) 
    END_MESSAGE_MAP() 
    //      
    BOOL CPropDialog3::OnInitDialog() 
    ( 
    CPropertyPage::OnInitDialog(); //     
    CButton *cbptr = (CButton *) GetDlgItem(IDD_RBl) ; 
    cbptr->SetCheck(1) ; 
    return TRUE; 
    1 
    //   OnApplyO  CPropDialog3 
    afx_msg BOOL CPropDialog3::OnApply() 
    ( 
    MessageBox("Selection Applied", "Third Page"); 
    return TRUE; 
    ) 
    //   IDD_TOP 


    13.                                              343 


    afx_msg void CPropDialog3::OnTop() 
    ( 
    CButton *lbptrl = (CButton *) GetDlgItem(IDD_RB1); 
    CButton *lbptr2 = (CButton *) GetDlgItem(IDD_RB2); 
    CButton *lbptr3 = (CButton *) GetDlgItem(IDD_RB3); 
    
    //    
    lbptr2->SetCheck(0) ; 
    lbptr3->SetCheck(0) ; 
    lbptrl->SetCheck(1); //    
    SetModified(l) ; 
    ) 
    
    //   IDD_BOTTOM 
    afx msg void CPropDialog3::OnBottom() 
    ( 
    CButton *lbptrl = (CButton *) GetDlgItem(IDD_RBl) 
    CButton *lbptr2 = (CButton *) GetDlgItem(IDD_RB2) 
    CButton *lbptr3 = (CButton *) GetDlgItem(IDD_RB3) 
    
    //    
    lbptr2->SetCheck<0) ; 
    lbptrl->SetCheck(0) ; 
    lbptr3->SetCheck(1); //    
    SetModified(l) ; 
    } 
    
    //   IDD RB1 
    afx_msg void CPropDialog3::OnRBl() 
    ( 
    SetModified(l) ; 
    > 
    
    //   IDD_RB2 
    afx_msg void CPropDialog3::OnRB2() 
    ( 
    SetModified(l) ; 
    } 
    
    //   IDD RB3 
    afx_msg void CPropDialog3::OnRB3() 
    { 
    SetModified(l) ; 
    } 
    
    CApp App; //    
         . 13.2. 


    344                                     MFC:   


    . 13.2.      


    13.                                                   345 


       ""      
.         .  
 PROP.H      ,   
CPropDialogI  CPropDialog3.       
CSamplePropSheet     .  ,  
     ,    , 
 .   (  )   
     .     
  ,      . 
      1()        
.        
.   ()  )    PROP.H   
.        . 
      (private)   CMainWin   
mJPropSheet,     CSamplePropSheet.  , 
   CApp::InitInstance()     
,     . 

      

    ,  ,    ,    
    .       
   .      
,    :    ,  
 ,        .  
     ,     : 
    1.   . 
    2.    ,     
   . 
    3. ,  ,  OnWizardFinish(), 
OnWizardNextQ  OnWizardBackQ. 
    4.  ,      . 
 ,      . 
       
       ,     ,    
.      ,   
   .    :   
   DoModalQ   SetWizardMode(),  
   CPropertySheet    : 

    void CPropertySheet::SetWizardMode() ; 

              
 . 


    346 MFC:   


       

        SetWzardModeQ     
  ,     ,   
   .  ,     
 ,   Back, Next  Finish.    
     . ,   
    Next,   Back   .  
     Back  Finish.  , 
    ,    Next  
Back.       
SetWizardButtons(),   : 

    void CPropertySheet::SetWizardButtons(DWORD dwWhich}; 

      dwWhich ,   ( )   
.       ,  
  .     : 

     PSWIZB_BACK 
     PSWIZB_DISABLEDFINISH 
     PSWIZB_FINISH 
     PSWIZB_NEXT 

               
,       . ,  
  Back  Finish    : 

    SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH) ; 

     PSWIZBJDISABLEDFINISH    Finish. 
     ,    
    . 

        

       ,     
.         . 
 CPropertyPage   -   
.       .   : 

    virtual void CPropertyPage::OnWizardBack(); 
    virtual void CPropertyPage::OnWizardNext(); 
    virtual void CPropertyPage::OnWizardFinish(); 

       ,  OnWizardBackQ    
 Back,  OnWizardNextQ     Next,   
OnWizardFinishO     Finish. 
          . ,  
     ,      
Finish.    Back    ,   
  Next    ,  . 

    13.                                               347 

      ,      
 1().       Cancel. 
    . 

       

    ,   ,       
       ,   
 .        
 .    , ,   , 
         
    .      
,    ,       
,    OnPaintQ.     
    ,      7. 

      

            , 
     ,   
 Microsoft.    (. 13.2): 

     13.2.   

           

    WtZ_CXDLG       
    WIZ_CYDLG       
    WIZ_CXBMP         
    WIZ_BODYX            
    WIZ_BODYCX        (   
 ) 

          ,  
  .      
         PRSHT.H. 
        ,     
,    Windows.      
     ,   
. , ,      ,   
   .       
  ,     . 

    348                                    MFC:   


        

          .     
,    ,   . 
           IDS.H,    
 .        
.  ,  ,    ,  
      . 

    ;     
    ^include <afxres.h> 
    ^include <prsht.h> 
    tinclude "ids.h" 
    wizbmp BITMAP bpl.bmp 
    PropertyMenu MENU ( 
    POPUP "^Wizard Demo" ( 
    
    MENUITEM "&Activate\tF2", IDM_ACTIVATE 
    MENUITEM "E&it\tF3", IDM_EXIT 
    ) 
    
    MENUITEM "SHelp", IDM_HELP 
    ) 
    PropertyMenu ACCELERATORS ( 
    VK_F2, IDM_ACTIVATE, VIRTKEY 
    VK_F3, IDM_EXIT, VIRTKEY 
    VK_F1, IDM_HELP, VIRTKEY 
     
    PropDialogI DIALOG 10, 10, WIZ_CXDLG, WIZ_CYDLG 
    Caption "Wizard Demo -- First Page" 
    STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU 1 WS_VISIBLE 
    ( 
    DEFPUSHBUTTON "One", IDD_ONE, WIZ_BODYX, 10, 32, 14, 
    
    WS_CHILD I WS_VISIBLE | WS_TABSTOP 
    PUSHBUTTON "Two", IDD_TWO, WIZ_BODYX, 34, 32, 14, 
    
    
    WS_CHILD | WS_VISIBLE | WS_TABSTOP 
    PUSHBUTTON "Three", IDD_THREE, WIZ_BODYX, 58, 32, 14, 
    
    WS_CHILD | WS_VISIBLE | WS_TABSTOP 
    LISTBOX IDD_LB1, WIZ_BODYX+66, 25, 50, 33, LBS__NOTIFY | 
    WS_VISIBLE | WS_BORDER | WS_VSCROLL I WS_TABSTOP 
    } 
    PropDialog2 DIALOG 10, 10, 110, 100 
    Caption "Wizard Demo -- Second Page" 
    STYLE WS_POPUP I WS_CAPTION | WS_SYSMENU | WS_VISIBLE 
    { 


    13.                                               349 


    DEFPUSHBUTTON "Invert", IDD_INVERT, WIZ_BODYX, 10, 32, 14, 
    WS_CHILD | WS_VISIBLE | WS_TABSTOP 
    
    AUTOCHECKBOX "Check Box I", IDD_CB1, WIZ_BODYX+66, 10, 70, 10 
    AUTOCHECKBOX "Check Box 2", IDD__CB2, WIZ_BODYX+66, 30, 70, 10 
    AUTOCHECKBOX "Check Box 3", IDD__CB3, WIZ_BODYX+66, 50, 70, 10 
    ) 
    PropDialog3 DIALOG 10, 10, 110, 100 
    Caption "Wizard Demo -- Third Page" 
    STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE 
    { 
    DEFPUSHBUTTON "Top", IDD_TOP, 11, 10, 32, 14, 
    
    WS_CHILD I WS_VISIBLE | WS_TABSTOP 
    PUSHBUTTON "Bottom", IDD_BOTTOM, 11, 34, 32, 14, 
    
    WS_CHILD I WS_VISIBLE I WS_TABSTOP 
    AUTORADIOBUTTON "Radio Button I", IDD_RB1, 66, 10, 70, 10 
    AUTORADIOBUTTON "Radio Button 2", IDD_RB2, 66, 30, 70, 10 
    AUTORADIOBUTTON "Radio Button 3", IDD_RB3, 66, 50, 70, 10 
    ) 
       WIZ.H,    : 
    //  WIZ.H 
    /* 
      ,      
  .        
  
    */ 
    //         
    class CPropDialogI : public CPropertyPage 
    { 
    CBitmap m_bmp; 
    public: 
    CPropDialogI() : CPropertyPage0 (}; 
    BOOL OnInitDialog() ; 
    BOOL OnWizardFinish(); 
    BOOL OnSetActive <) ; 
    /*       : 
    
    void OnCancelO; //     Cancel 
    void OnWizardBack(); //     Back 
    void OnWizardNext(); //     Next 
    */ 
    afx_msg void On0ne(); 
    afx msg void OnTwoO; 


    350                                     MFC:   


    afx msg void OnThree(); 
    afx_msg void OnListBoxO; 
    afx msg void OnPaintf); 
    DECLARE_MESSAGE_MAP () 
    ); 
    //         
    class CPropDialog2 : public CPropertyPage 
    ( 
    CBitmap m bmp; 
    public: 
    CPropDialog2() : CPropertyPage() {}; 
    BOOL OnInitDialog(); 
    BOOL OnWizardFinish(); 
    BOOL OnSetActive (); 
    /*       : 
    
    void OnCancelO; //     Cancel 
    void OnWizardBack(); //     Back 
    void OnWizardNext(); //     Next 
    */ 
    afx msg void OnInvertO; 
    afx msg void OnCBlO; 
    afx_msg void OnCB2(); 
    afx msg void OnCB3(); 
    afx msg void OnPaintO; 
    DECLARE_MESSAGE_MAP() 
    ); 
    
    //         
    class CPropDialog3 : public CPropertyPage 
    { 
    public: 
    CPropDialog3() : CPropertyPage() (}; 
    BOOL OnInitDialog() ; 
    BOOL OnWizardFinish() ; 
    BOOL OnSetActive() ; 
    /* .      : 
    void OnCancelO; //     Cancel 
    void OnWizardBack(); //     Back 


    13.                                               351 


    void OnWizardNext (); //     Next 
    */ 
    afx msg void OnTopO; 
    afx msg void OnBottomO; 
    afx_insg void OnRBl(); 
    afx_msg void OnRB2(); 
    afx_msg void OnRB3(); 
    DECLARE_MESSAGE_MAP() 
    }; 
    //       
    class CSamplePropSheet : "public CPropertySheet 
    { 
    CPropDialogI pagel; //   
    CPropDialog2 page2; //   
    CPropDialog3 ; //   
    public: 
    CSamplePropSheet () : CPropertySheet () 
    ( 
    Construct("Sample Wizard", this); 
    pagel.Construct("PropDialogI", 0) ; 
    pagel.Construct("PropDialog2", 0) ; 
    pagel.Construct("PropDialog3", 0) ; 
    AddPage(bpagel) ; 
    AddPage(&page2) ; 
    AddPage(&page3) ; 
    ) 
    }; 
    //       
    class CMainWin : public CFrameWnd 
    { 
    CSamplePropSheet m_PropSheet; //    
    public: 
    CMainWin() ; 
    afx msg void OnActivate(); 
    afx_msg void OnExitO; 
    afx_msg void OnHelpO; 
    DECLARE_MESSAGE_MAP() 
    }; 
    //      
    class CApp : public CWinApp 
    { 
    public: 


    352                                    MFC:   


    BOOL Initlnstance (); 
    1; 
        : 
    //    
    
    #include <afxwin.h> 
    I  #include <afxdlgs.h> 
    |  #include <string.h> 
    |  #include "ids.h" 
    ^include "wiz.h" 
    CSamplePropSheet *PropSheetPtr; //      
    char list[][40] = ( 
    "Red", 
    "Green", 
    "Yellow", 
    "Black", 
    "White", 
    ); 
    //     
    CMainWin:;CMainWin() 
    ( 
    Create(NULL, "Using A Wizard", 
    WS_OVERLAPPEDWINDOW, rectDefault, 
    NULL, "PropertyMenu"); 
    InitCommonControls () ; 
    
    //     
    if(!LoadAccelTable("PropertyMenu" ) ) 
    MessageBox ("Cannot Load Accelerators", "Error"); 
    PropSheetPtr = &m_PropSheetPtr; //   
    //     
    ) 
    
    //   
    BOOL CApp::Initlnstance () 
    ( 
    m_pMainWnd = new CMainWin; 
    m pMainWnd->ShowWindow(m nCmdShow) ; 
    m_pMainWnd->UpdateWindow() ; 
    return TRUE; 
    
    //     
    BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) 


    13.                                               353 


    ON_COMMAND(IDM_ACTIVATE, OnActivate)                                
    ON_COMMAND(IDM_EXIT, OnExit) 
    ON__COMMAND(IDM_HELP, OnHelp) 
    END__MESSAGE_MAP() 
    //   IDM_ACTIVATE 
    afx__msg void CMainWin::OnActivate() 
    ( 
    
    m_PropSheet.SetWizardMode(); //    
    m_PropSheet.DoModal(); //     
    } 
    //   IDM_EXIT                                      ; 
    afx msg void CMainWin::OnExit { 
    int response; 
    s 
    response = MessageBox("Quit the Program?", "Exit", MB YESNO);      ! 
    
    if (response == IDYES)                                               ^ 
    SendMessage(WM_CLOSE); //   
    i 
    //   IDM HELP                                      ^ 
    afx_msg void CMainWin::OnHelp<) 
    ( 
    MessageBox ( "Wizard", "Help") ; 
    } 
    //                   j 
    BEGIN_MESSAGE_MAP(CPropDialogI, CPropertyPage)                       ! 
    ON_WM_PAINT() 
    ON_COMMAND(IDD_ONE, OnOne) 
    ON_COMMAND(IDD_TWO, OnTwo) 
    ON_COMMAND(IDD_THREE, OnThree) 
    
    ON_LBN_DBLCLK(IDD_LB1, OnListBox) 
    END_MESSAGE_MAP() 
    //      
    BOOL CPropDialogI::OnInitDialog() 
    ( 
    int i; 
    
    CPropertyPage::OnInitDialog; //     
    CListBox *lbptr = (CListBox *) GetDlgItem(IDD_LB1); 
    for(i=0; KNUMSTRINGS; i++) 
    lbptr->AddString(list[i]) ; 
    ibptr->SetCurSel (0); 
    < 


    354                                     MFC:   


    m bmp.LoadBitmap("wizbmp"); 
    return TRUE; 
    ! 
    //   
    afx_msg void CPropDialogI::OnPaint() 
    ( 
    CPaintDC DC(this) ; 
    CDC memDC; 
    
    //     
    memDC.CreateCompatibleDC(&DC) ; 
    
    //       
    memDC.SelectObject(&m_bmp) ; 
    
    //      
    DC.BitBlt(0, 0, 129, 226, bmemDC, 0, , SRCCOPY) ; 
    ] 
    
    I /    
    afx_msg BOOL CPropDialogI::OnSetActive() 
    ( 
    PropSheetPtr->SetWizardButtons(PSWIZB_NEXT) ; 
    return TRUE; 
    ) 
    //   OnWizardFinish()  CPropDialogI 
    afx_msg BOOL CPropDialogI::OnWizardFinish() 
    ( 
    MessageBox("Wizard Finished", "First Page"); 
    return TRUE; 
    
    //   IDD ONE 
    afx msg void CPropDialogI::0n0ne() 
    ( 
    MessageBox ( "One", "Button Pressed"); 
    ) 
    
    //   IDD_TWO 
    afx msg void CPropDialogI::OnTwo() 
    { 
    MessageBox("Two", "Button Pressed"); 
    
    //   IDD_THREE 
    afx msg void CPropDialogI::OnThree() 
    ( 


    13.                                               355 


    MessageBox ("Three", "Button Pressed"); 
    } 
    //     
    afx_msg void CPropDialogI::OnListBox() 
    ( 
    int it
    char str[255] ; 
    CListBox *lbptr = (CListBox *) GetDlgItem(IDD_LB1); 
    i = !bptr->GetCurSel (); 
    lbptr->GetText (i, str); 
    MessageBox (str, "Selection is"); 
    SetModified(l) ; 
    ) 
    
    //        
    BEGIN_MESSAGE_MAP(CPropDialog2, CPropertyPage) 
    ON_WM_PAINT() 
    ON_COMMAND(IDD_INVERT, Onlnvert) 
    ON_COMMAND(IDD_CB1, OnCBl) 
    ON_COMMAND(IDD_CB2, OnCB2) 
    
    ON_COMMAND(IDD_CB3, ) 
    END_MESSAGE_MAP() 
    //      
    BOOL CPropDialog2::OnInitDialog() 
    ( 
    CPropertyPage::OnInitDialog; //     
    CButton *cbptr = (CButton *) GetDlgItem(IDD_CB1); 
    cbptr->SetCheck(1) ; 
    m bmp.LoadBitmap("wizbmp"); 
    return TRUE; 
    } 
    //   
    afx msg void CPropDialog2::OnPaint() 
    ( 
    CPaintDC DC(this) ; 
    CDC memDC; 
    
    //     
    memDC.CreateCompatibleDC(&DC) ; 
    //                          : 


    356                                    MFC:   


    memDC . Select-Object ( & bmp) ; 
    
    //      
    DC.BitBlt(0, 0, 129, 226, SmernDC, 0, , SRCCOPY); 
    //    
    afx_msg BOOL CPropDialog2::OnSetActive() 
    ( 
    PropSheetPtr->SetWizardButtons(PSWIZB_NEXT I PSWIZB^BACK); 
    return TRUE; 
    \ 
    II   OnWizardFinish()  CPropbialog2 
    afx_msg BOOL CPropDialog2::OnWizardFinish() 
    ( 
    
    MessageBox("Wizard Finished", "Second Page"it
    return TRUE; 
    ) 
    //   IDD INVERT 
    afx msg void CPropDialog2::0nlnvert() 
    1 
    CButton *lbptrl = (CButton *) GetDlgItem(IDD_CBl) ; 
    CButton *lbptr2 = (CButton *) GetDlgItem(IDD_CB2) ; 
    CButton *lbptr3 = (CButton *) GetDlgItem(IDD_CB3); 
    
    //     
    if(lbptrl->GetCheck()) lbptrl->SetCheck(0) ; 
    else lbptrl->SetCheck(1) ; 
    if(lbptr2->GetCheck()) lbptr2->SetCheck(0) ; 
    else lbptr2->SetCheck(l) ; 
    if (lbptr3->GetCheck()) lbptr3->SetCheck(0) ; 
    else lbptr3->SetCheck(1) ; 
    SetModified(l) ; 
    ) 
    
    //   IDD CB1 
    afx msg void CPropDialog2::OnCBl() 
    { 
    SetModified(l) ; 
    ) 
    
    //   IDD_CB2 
    afx_msg void CPropDialog2::OnCB2() 
    1 
    SetModified(l) ; 


    13.                                               357 


    //   IDD_CB3                                       i 
    afx msg void CPropDialog2::OnCB3<) 
    ( 
    SetModified(l) ; 
    } 
    
    //        
    BEGIN_MESSAGE_MAP(CPropDialog3, CPropertyPage)                       J 
    ON_COMMAND(IDD_TOP, OnTop)                                           ' 
    ON_COMMAND(IDD_BOTTOM, OnBottom) 
    ON_COMMAND(IDD_RB1, OnRBl) 
    ON_COMMAND(IDD_RB2, OnRB2) 
    
    ON_COMMAND(IDD_RB3, OnRB3) 
    END_MESSAGE_MAP() 
    //      
    BOOL CPropDialog3::OnInitDialog() 
    ( 
    CPropertyPage::OnInitDialog(); //     
    CButton *cbptr = (CButton *) GetDlgItem(IDD_RBl); 
    cbptr->SetCheck(l) ; 
    return TRUE; 
    ) 
    //    
    afx_msg BOOL CPropDialog3::OnSetActive() 
    ( 
    PropSheetPtr->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH); 
    return TRUE; 
    i 
    //   OnWizardFinish()  CPropDialog3 
    afx_msg BOOL CPropDialog3::OnWizardFinish() 
    ( 
    MessageBox("Wizard Finished", "Third Page"); 
    return TRUE; 
    } 
    
    //   IDD TOP 
    afx msg void CPropDialog3::OnTop () 
    ( 
    CButton *lbptrl = (CButton *) GetDlgItem(IDD_RBl) ; 
    CButton *lbptr2 = (CButton *) GetDlgItem(IDD_RB2) ; 
    CButton *lbptr3 = (CButton *) GetDlgItem(IDD_RB3) ; 


    358                                     MFC:   


    //    
    lbptr2->SetCheck(0) ; 
    lbptr3->SetCheck(0) ; 
    
    lbptrl->SetCheck(1) ; //    
    SetModified(l) ; 
    //   IDD_BOTTOM 
    afx msg void CPropDialog3::OnBottom() 
    ( 
    CButton *lbptrl = (CButton *) GetDlgItem(IDD_RBl); 
    CButton *lbptr2 = (CButton *) GetDlgItem(IDD_RB2); 
    CButton *lbptr3 = (CButton *) GetDlgItem(IDD_RB3); 
    
    //    
    lbptr2->SetCheck (0) ; 
    lbptrl->SetCheck (0) ; 
    lbptr3->SetCheck (1); //    
    SetModified(l) ; 
    } 
    
    //   IDD_RB1 
    afx_msg void CPropDialog3::OnRBl() 
    { 
    SetModified(l) ; 
    ) 
    
    //   IDD_RB2 
    afx_msg void CPropDialog3::OnRB2() 
    { 
    SetModified(l) ; 
    
    //   IDD RB3 
    afxJ-nsg void CPropDialog3 : :OnRB3 () 
    ( 
    SetModified(l) ; 
    ) 
    CApp App; //    
         . 13.3. 


    13.                                               359 


    . 13.3.     


    360                                         MFC:   

     ,    ,    
,  ,    .  , 
 OnSetActiveQ      ,  
          
.  ,        
PropSheetPtr.     CMainWinQ    
   .       
     SetWizardButtonsQ.   
OnSetActive()    CPropertyPage (  CPropertySheet),  
 SetWizardButtonsQ    CPropertySheet (  
CPropertyPage),          
.         . 
     , ,       
.      ,   
,       WIZ_BODYX. 
,         . 
 ,       . 

         

             
Windows.  ,       
    ,  . ,  
        
   / . ,     
         
  ,    
   .   ,      
  . 

    13.                                               361