다음을 통해 공유


CPropertyPage 클래스

속성 시트(탭 대화 상자라고도 함)의 개별 페이지를 나타냅니다.

구문

class CPropertyPage : public CDialog

멤버

공용 생성자

속성 설명
CPropertyPage::CPropertyPage CPropertyPage 개체를 생성합니다.

공용 메서드

이름 설명
CPropertyPage::CancelToClose 확인 단추를 변경하여 닫기를 읽고 모달 속성 시트 페이지에서 복구할 수 없는 변경 후 취소 단추를 사용하지 않도록 설정합니다.
CPropertyPage::Construct CPropertyPage 개체를 생성합니다. 런타임에 매개 변수를 지정하거나 배열을 사용하는 경우 사용합니다 Construct .
CPropertyPage::GetPSP 개체와 연결된 Windows PROPSHEETPAGE 구조를 검색합니다 CPropertyPage .
CPropertyPage::OnApply 지금 적용 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::OnCancel 취소 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::OnKillActive 현재 페이지가 더 이상 활성 페이지가 아니면 프레임워크에서 호출됩니다. 여기에서 데이터 유효성 검사를 수행합니다.
CPropertyPage::OnOK 확인, 지금 적용 또는 닫기 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::OnQueryCancel 취소 단추를 클릭할 때 및 취소 가 수행되기 전에 프레임워크에서 호출됩니다.
CPropertyPage::OnReset 취소 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::OnSetActive 페이지가 활성 페이지로 설정되면 프레임워크에서 호출됩니다.
CPropertyPage::OnWizardBack 마법사 형식 속성 시트를 사용하는 동안 뒤로 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::OnWizardFinish 마법사 유형 속성 시트를 사용하는 동안 마침 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::OnWizardNext 마법사 형식 속성 시트를 사용하는 동안 다음 단추를 클릭할 때 프레임워크에서 호출됩니다.
CPropertyPage::QuerySiblings 속성 시트의 각 페이지에 메시지를 전달합니다.
CPropertyPage::SetModified 지금 적용 단추를 활성화하거나 비활성화하기 위해 호출합니다.

공용 데이터 멤버

이름 설명
CPropertyPage::m_psp Windows PROPSHEETPAGE 구조체입니다. 기본 속성 페이지 매개 변수에 대한 액세스를 제공합니다.

설명

표준 대화 상자와 마찬가지로 속성 시트의 각 페이지에서 클래스 CPropertyPage 를 파생합니다. 파생 개체를 사용 CPropertyPage하려면 먼저 개체를 CPropertySheet 만든 다음 속성 시트에 있는 각 페이지에 대한 개체를 만듭니다. 시트의 각 페이지를 호출 CPropertySheet::AddPage 한 다음 모달 속성 시트 또는 CPropertySheet::Create 모덜리스 속성 시트를 호출 CPropertySheet::DoModal 하여 속성 시트를 표시합니다.

마법사라는 탭 대화 상자 유형을 만들 수 있습니다. 이 대화 상자는 디바이스 설정 또는 뉴스레터 만들기와 같은 작업 단계를 안내하는 속성 페이지 시퀀스가 있는 속성 시트로 구성됩니다. 마법사 유형 탭 대화 상자에서 속성 페이지에는 탭이 없으며 한 번에 하나의 속성 페이지만 표시됩니다. 또한 확인 및 지금 적용 단추 대신 마법사 유형 탭 대화 상자에는 뒤로 단추, 다음 또는 마침 단추, 취소 단추가 있습니다.

속성 시트를 마법사로 설정하는 방법에 대한 자세한 내용은 다음을 참조하세요 CPropertySheet::SetWizardMode. 개체 사용에 CPropertyPage 대한 자세한 내용은 속성 시트 및 속성 페이지 문서를 참조하세요.

상속 계층 구조

CObject

CCmdTarget

CWnd

CDialog

CPropertyPage

요구 사항

헤더afxdlgs.h:

CPropertyPage::CancelToClose

모달 속성 시트 페이지의 데이터를 복구할 수 없는 변경이 수행된 후 이 함수를 호출합니다.

void CancelToClose();

설명

이 함수는 확인 단추를 닫도록 변경하고 취소 단추를 사용하지 않도록 설정합니다. 이렇게 변경하면 사용자에게 변경 내용이 영구적이고 수정 내용을 취소할 수 없다는 알림이 표시됩니다.

모덜리스 속성 시트에는 CancelToClose 기본적으로 취소 단추가 없으므로 멤버 함수는 모덜리스 속성 시트에서 아무 작업도 수행하지 않습니다.

예시

CPropertyPage::QuerySiblings에 대한 예제를 참조하세요.

CPropertyPage::Construct

이 멤버 함수를 호출하여 개체를 생성합니다 CPropertyPage .

void Construct(
    UINT nIDTemplate,
    UINT nIDCaption = 0);

void Construct(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption = 0);

void Construct(
    UINT nIDTemplate,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0);

void Construct(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0);

매개 변수

nIDTemplate
이 페이지에 사용되는 템플릿의 ID입니다.

nIDCaption
이 페이지의 탭에 배치할 이름의 ID입니다. 0이면 이 페이지의 대화 상자 템플릿에서 이름을 가져옵니다.

lpszTemplateName
템플릿 리소스의 이름인 null로 끝나는 문자열을 포함합니다.

nIDHeaderTitle
속성 페이지 머리글의 제목 위치에 배치할 이름의 ID입니다. 기본적으로 0입니다.

nIDHeaderSubTitle
속성 페이지 머리글의 자막 위치에 배치할 이름의 ID입니다. 기본적으로 0입니다.

설명

다음 조건이 모두 충족되면 개체가 표시됩니다.

  • 를 사용하여 CPropertySheet::AddPage속성 시트에 페이지가 추가되었습니다.

  • 속성 시트 DoModal 또는 Create 함수가 호출되었습니다.

  • 사용자가 이 페이지를 선택했습니다(탭으로 이동).

다른 클래스 생성자 중 하나가 호출되지 않은 경우 호출 Construct 합니다. Construct 매개 변수 문을 비워 둔 다음 코드의 어느 지점에서든 여러 매개 변수 및 생성을 지정할 수 있으므로 멤버 함수는 유연합니다.

배열을 사용할 때 사용해야 Construct 하며, 데이터 멤버에 적절한 값이 할당되도록 배열의 각 멤버를 호출 Construct 해야 합니다.

예시

// Declare a CPropertySheet object.
CPropertySheet sheet(_T("Simple PropertySheet"));

// Create three CPropertyPage objects whose template IDs are specified
// in rgID array, and add each page to the CPropertySheet object. 
const int c_cPages = 3;
CPropertyPage   pages[c_cPages];
UINT rgID[c_cPages] = { IDD_STYLE, IDD_COLOR, IDD_SHAPE };
for (int i = 0; i < c_cPages; i++)
{
   pages[i].Construct(rgID[i]);
   sheet.AddPage(&pages[i]);
}

// Display a modal CPropertySheet dialog.
sheet.DoModal();

CPropertyPage::CPropertyPage

CPropertyPage 개체를 생성합니다.

CPropertyPage();

explicit CPropertyPage(
    UINT nIDTemplate,
    UINT nIDCaption = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

explicit CPropertyPage(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

CPropertyPage(
    UINT nIDTemplate,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

CPropertyPage(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

매개 변수

nIDTemplate
이 페이지에 사용되는 템플릿의 ID입니다.

nIDCaption
이 페이지의 탭에 배치할 이름의 ID입니다. 0이면 이 페이지의 대화 상자 템플릿에서 이름을 가져옵니다.

dwSize
lpszTemplateName 이 페이지의 템플릿 이름을 포함하는 문자열을 가리킵니다. 할 수 없습니다 NULL.

nIDHeaderTitle
속성 페이지 머리글의 제목 위치에 배치할 이름의 ID입니다.

nIDHeaderSubTitle
속성 페이지 머리글의 자막 위치에 배치할 이름의 ID입니다.

설명

다음 조건이 모두 충족되면 개체가 표시됩니다.

  • 를 사용하여 CPropertySheet::AddPage속성 시트에 페이지가 추가되었습니다.

  • 속성 시트 DoModal 또는 Create 함수가 호출되었습니다.

  • 사용자가 이 페이지를 선택했습니다(탭으로 이동).

여러 매개 변수가 있는 경우(예: 배열을 사용하는 경우) 대신 CPropertyPage사용합니다CPropertySheet::Construct.

예시

// Declare a CStylePage object, which is a CPropertyPage-derived class.
CStylePage stylePage;

// Declare a CPropertyPage object with IDD_SHAPE, the ID of the 
// template used for this page. 
CPropertyPage shapePage(IDD_SHAPE);

CPropertyPage::GetPSP

개체와 연결된 Windows PROPSHEETPAGE 구조를 검색합니다 CPropertyPage .

const PROPSHEETPAGE& GetPSP() const;

PROPSHEETPAGE& GetPSP();

Return Value

구조체에 대한 참조입니다 PROPSHEETPAGE .

CPropertyPage::m_psp

m_psp 는 멤버가 .의 특성을 저장하는 구조체입니다 PROPSHEETPAGE.

PROPSHEETPAGE m_psp;

설명

이 구조를 사용하여 생성된 후 속성 페이지의 모양을 초기화합니다.

멤버 목록을 포함하여 이 구조에 대한 자세한 내용은 Windows SDK를 참조 PROPSHEETPAGE 하세요.

예시

CPropertySheet sheet(_T("Simple PropertySheet"));

// Change the settings of the three pages to enable property sheet's 
// Help button when the page is active.  CStylePage, CShapePage, and 
// CColorPage are CPropertyPage-derived classes.
CStylePage pageStyle;
pageStyle.m_psp.dwFlags |= PSP_HASHELP;

CColorPage pageColor;
pageColor.m_psp.dwFlags |= PSP_HASHELP;

CShapePage pageShape;
pageShape.m_psp.dwFlags |= PSP_HASHELP;

sheet.AddPage(&pageStyle);
sheet.AddPage(&pageColor);
sheet.AddPage(&pageShape);

sheet.SetWizardMode();

sheet.DoModal();

CPropertyPage::OnApply

이 멤버 함수는 사용자가 확인 또는 지금 적용 단추를 선택할 때 프레임워크에서 호출됩니다.

virtual BOOL OnApply();

Return Value

변경 내용이 허용되는 경우 0이 아닌 경우 그렇지 않으면 0입니다.

설명

프레임워크가 이 함수를 호출하면 속성 시트의 모든 속성 페이지에 대한 변경 내용이 허용되고 속성 시트는 포커스 OnApply 를 유지하고 값 1을 반환 TRUE 합니다. 프레임워크에서 호출하려면 먼저 OnApply 해당 매개 변수를 호출 SetModified 하고 해당 매개 변수를 TRUE.로 설정해야 합니다. 그러면 사용자가 속성 페이지를 변경하는 즉시 지금 적용 단추가 활성화됩니다.

이 멤버 함수를 재정의하여 사용자가 지금 적용 단추를 선택할 때 프로그램에서 수행하는 작업을 지정합니다. 재정의할 때 함수는 변경 내용을 수락하고 FALSE 변경 내용이 적용되지 않도록 반환 TRUE 해야 합니다.

호출OnOK의 기본 구현입니다OnApply.

사용자가 속성 시트에서 지금 적용 또는 확인 단추를 누를 때 전송되는 알림 메시지에 대한 자세한 내용은 Windows SDK를 참조 PSN_APPLY 하세요.

예시

CPropertyPage::OnOK에 대한 예제를 참조하세요.

CPropertyPage::OnCancel

이 멤버 함수는 취소 단추를 선택할 때 프레임워크에서 호출됩니다.

virtual void OnCancel();

설명

취소 단추 작업을 수행하려면 이 멤버 함수를 재정의합니다. 기본값은 변경된 내용을 부정합니다.

예시

// Discard any selection the user made to this page.  The object
// in the view will be painted with the initial color when the
// CPropertySheet dialog is first shown. CColorPage is a 
// CPropertyPage-derived class.
void CColorPage::OnCancel()
{
   // Reset the color saved in the document class.  m_InitialColor
   // is a member variable of CColorPage and it is the color shown 
   // in the view before CPropertySheet is shown.
   // doc->m_Color is the color saved in the document class, and 
   // this is the color to be used by the view class.
   CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetMainWnd();
   CMDIChildWnd* pChild = pFrame->MDIGetActive();
   CPSheetDoc* doc = (CPSheetDoc*)pChild->GetActiveDocument();
   doc->m_Color = m_InitialColor;

   // Tell the view to paint with the initial color.
   CView* view = pChild->GetActiveView();
   view->Invalidate();

   CPropertyPage::OnCancel();
}

// The default MFC implementation of OnReset() would call OnCancel().
void CColorPage::OnReset()
{
   CPropertyPage::OnReset();
}

CPropertyPage::OnKillActive

이 멤버 함수는 페이지가 더 이상 활성 페이지가 될 때 프레임워크에서 호출됩니다.

virtual BOOL OnKillActive();

Return Value

데이터가 성공적으로 업데이트되었으면 0이 아니고, 그렇지 않으면 0입니다.

설명

특수 데이터 유효성 검사 작업을 수행하려면 이 멤버 함수를 재정의합니다.

이 멤버 함수의 기본 구현은 속성 페이지의 컨트롤에서 속성 페이지의 멤버 변수로 설정을 복사합니다. DDV(대화 상자 데이터 유효성 검사) 오류로 인해 데이터가 성공적으로 업데이트되지 않은 경우 페이지에 포커스가 유지됩니다.

이 멤버 함수가 성공적으로 반환되면 프레임워크는 페이지의 OnOK 함수를 호출합니다.

예시

// Validate the value entered to the "Number" edit control. Its
// value must be at least one. If not, tell the user and set the
// focus to the "Number" edit control. CStylePage is a 
// CPropertyPage-derived class.
BOOL CStylePage::OnKillActive() 
{
   int num = GetDlgItemInt(IDC_NUMOBJECTS);
   if (num <= 0)
   {
      AfxMessageBox(_T("Number of objects must be at least 1."));
      CEdit* edit = (CEdit*) GetDlgItem(IDC_NUMOBJECTS);
      edit->SetFocus();
      edit->SetSel(0, -1);
      return 0;
   }

   return CPropertyPage::OnKillActive();
}

CPropertyPage::OnOK

이 멤버 함수는 프레임워크가 호출된 직후 사용자가 확인 또는 지금 적용 단추를 선택할 때 프레임워크에서 호출 OnKillActive 됩니다.

virtual void OnOK();

설명

사용자가 확인 또는 지금 적용 단추를 선택하면 프레임워크가 속성 페이지에서 알림을 받 PSN_APPLY 습니다. 이 경우 속성 페이지에서 알림을 보내지 않으므로 호출하는 경우 호출 OnOKCPropertySheet::PressButton 이 이루어지지 않습니다.

사용자가 전체 속성 시트를 해제할 때 현재 활성 페이지와 관련된 추가 동작을 구현하도록 이 멤버 함수를 재정의합니다.

이 멤버 함수의 기본 구현은 데이터가 함수에서 OnKillActive 업데이트되었음을 반영하기 위해 페이지를 "클린"로 표시합니다.

예시

// Accept the new color selection and dismiss the CPropertySheet
// dialog. The view's object will be painted with the new selected
// color. CColorPage is a CPropertyPage-derived class.
void CColorPage::OnOK() 
{
   // Store the new selected color to a member variable of 
   // document class.  m_Color is a member varible of CColorPage 
   // and it stores the new selected color.  doc->m_Color is 
   // the color saved in the document class and it is the color 
   // used by the view class.
   CMDIFrameWnd* pframe = (CMDIFrameWnd*) AfxGetMainWnd();
   CMDIChildWnd* pchild = pframe->MDIGetActive();
   CPSheetDoc* doc = (CPSheetDoc*) pchild->GetActiveDocument();
   doc->m_Color = m_Color;

   // Tell the view to paint with the new selected color.
   CView* view = pchild->GetActiveView();
   view->Invalidate();
  
   CPropertyPage::OnOK();
}

// The default MFC implementation of OnApply() would call OnOK().
BOOL CColorPage::OnApply() 
{
   return CPropertyPage::OnApply();
}

CPropertyPage::OnQueryCancel

이 멤버 함수는 사용자가 취소 단추를 선택하고 취소 작업이 수행되기 전에 프레임워크에서 호출됩니다.

virtual BOOL OnQueryCancel();

Return Value

취소 작업을 방지하거나 TRUE 허용하려면 반환 FALSE 합니다.

설명

이 멤버 함수를 재정의하여 사용자가 취소 단추를 선택할 때 프로그램에서 수행하는 작업을 지정합니다.

반환TRUE의 기본 구현입니다OnQueryCancel.

예시

// Query the user whether to abort the changes if the new selected
// color (m_Color) is different from the initial color 
// (m_InitialColor) when the CPropertySheet dialog is first shown.
// CColorPage is a CPropertyPage-derived class.
BOOL CColorPage::OnQueryCancel() 
{
   if (m_InitialColor != m_Color)
   {
      if (AfxMessageBox(_T("Abort the changes?"), MB_YESNO) == IDNO)
         return FALSE;  
   }

   return CPropertyPage::OnQueryCancel();
}

CPropertyPage::OnReset

이 멤버 함수는 사용자가 취소 단추를 선택할 때 프레임워크에서 호출됩니다.

virtual void OnReset();

설명

프레임워크에서 이 함수를 호출하면 이전에 [지금 적용] 단추를 선택한 사용자가 변경한 모든 속성 페이지가 해제되고카드 속성 시트가 포커스를 유지합니다.

이 멤버 함수를 재정의하여 사용자가 취소 단추를 선택할 때 프로그램에서 수행하는 작업을 지정합니다.

기본 구현은 OnReset 아무 것도 수행하지 않습니다.

예시

CPropertyPage::OnCancel에 대한 예제를 참조하세요.

CPropertyPage::OnSetActive

이 멤버 함수는 사용자가 페이지를 선택하고 활성 페이지가 될 때 프레임워크에서 호출됩니다.

virtual BOOL OnSetActive();

Return Value

페이지가 활성으로 설정된 경우 0이 아닌 경우 그렇지 않으면 0입니다.

설명

페이지가 활성화될 때 작업을 수행하도록 이 멤버 함수를 재정의합니다. 이 멤버 함수의 재정의는 일반적으로 데이터 멤버를 업데이트한 후 기본 버전을 호출하여 페이지 컨트롤을 새 데이터로 업데이트할 수 있도록 합니다.

기본 구현은 이전에 만들지 않은 경우 페이지의 창을 만들고 활성 페이지로 만듭니다.

예시

CPropertySheet::SetFinishText에 대한 예제를 참조하세요.

CPropertyPage::OnWizardBack

이 멤버 함수는 사용자가 마법사에서 뒤로 단추를 선택할 때 프레임워크에서 호출됩니다.

virtual LRESULT OnWizardBack();

Return Value

0이면 자동으로 다음 페이지로 이동됩니다. 페이지가 변경되지 않도록 하려면 -1입니다. 다음 페이지가 아닌 다른 페이지로 이동하려면 표시할 대화 상자의 식별자를 반환합니다.

설명

뒤로 단추를 누를 때 사용자가 수행해야 하는 작업을 지정하려면 이 멤버 함수를 재정의합니다.

마법사 유형 속성 시트를 만드는 방법에 대한 자세한 내용은 다음을 참조하세요 CPropertySheet::SetWizardMode.

예시

// The Back button is selected from the propertysheet.  Get the selected 
// radio button of the page by looping through all buttons on the 
// pages.  m_radioColor is a member variable of 
// CColorPage (a CPropertyPage-derived class).  Its initial value 
// is initialized in OnInitDialog().
LRESULT CColorPage::OnWizardBack()
{
   for (int id = IDC_RADIOBLACK; id <= IDC_RADIOGREEN; id++)
   {
      CButton* button = (CButton*)GetDlgItem(id);
      if (button->GetCheck() == 1)
      {
         m_radioColor = id - IDC_RADIOBLACK;
         break;
      }
   }

   return CPropertyPage::OnWizardBack();
}

CPropertyPage::OnWizardFinish

이 멤버 함수는 사용자가 마법사에서 마침 단추를 선택할 때 프레임워크에서 호출됩니다.

virtual BOOL OnWizardFinish();

Return Value

마법사가 완료될 때 속성 시트가 제거되면 0이 아닙니다. 그렇지 않으면 0입니다.

설명

사용자가 마법사에서 마침 단추를 선택하면 프레임워크는 이 함수를 호출합니다. 반환 TRUE 할 때OnWizardFinish(0이 아닌 값) 속성 시트를 제거할 수 있지만 실제로는 제거되지 않습니다. 속성 시트를 삭제하려면 호출 DestroyWindow 합니다. 호출 DestroyWindowOnWizardFinish하지 마세요. 이렇게 하면 힙 손상 또는 기타 오류가 발생합니다.

이 멤버 함수를 재정의하여 마침 단추를 누를 때 사용자가 수행해야 하는 작업을 지정할 수 있습니다. 이 함수를 재정의할 때 속성 시트가 제거되지 않도록 반환 FALSE 합니다.

사용자가 마법사 속성 시트에서 마침 단추를 누를 때 전송되는 알림 메시지에 대한 자세한 내용은 Windows SDK를 참조 PSN_WIZFINISH 하세요.

마법사 유형 속성 시트를 만드는 방법에 대한 자세한 내용은 다음을 참조하세요 CPropertySheet::SetWizardMode.

예시

// Inform users regarding the selections they have made by 
// navigating the pages in propertysheet.
BOOL CShapePage::OnWizardFinish()
{
   CString report = _T("You have selected the following options:\n");

   // Get the number of property pages from CPropertySheet.
   CPropertySheet* sheet = (CPropertySheet*)GetParent();
   int count = sheet->GetPageCount();

   // Get the formatted string from each page. This formatted string 
   // will be shown in a message box. Each page knows about the 
   // string to be displayed. For simplicity, we derive a class 
   // from CPropertyPage called CMyPropertyPage. CMyPropertyPage 
   // has a pure virtual member function called GetPageSelections().
   // All pages in the property sheet must be derived from 
   // CMyPropertyPage so we loop through each page to get the 
   // formatted string by calling the GetPageSelections() function.
   for (int i = 0; i < count; i++)
   {
      CMyPropertyPage* page = (CMyPropertyPage*)sheet->GetPage(i);

      CString str;
      page->GetPageSelections(str);
      report += _T("\n") + str;
   }

   AfxMessageBox(report);

   return CPropertyPage::OnWizardFinish();
}

 

// An example of implementing the GetPageSelections() for CStylePage.
// CStylePage is a CMyPropertyPage-derived class, which in turn is a 
// CPropertyPage-derived class.
void CStylePage::GetPageSelections(CString& str)
{
   str.Format(_T("Number of objects to be created = %d"), m_NumObjects);
}

 

// An example of implementing the GetPageSelections() for CColorPage.
// CColorPage is a CMyPropertyPage-derived class, which in turn is a 
// CPropertyPage-derived class.
void CColorPage::GetPageSelections(CString& str)
{
   str = _T("Color selected is ");
   switch (m_Color)
   {
   case RGB(0, 0, 0):
      str += _T("Black");
      break;

   case RGB(255, 0, 0):
      str += _T("Red");
      break;

   case RGB(0, 255, 0):
      str += _T("Green");
      break;

   case RGB(0, 0, 255):
      str += _T("Blue");
      break;

   default:
      str += _T("Custom");
      break;
   }
}

 

// An example of implementing the GetPageSelections() for CShapePage.
// CShapePage is a CMyPropertyPage-derived class, which in turn is a 
// CPropertyPage-derived class.
void CShapePage::GetPageSelections(CString& str)
{
   CString shapename;
   switch (m_Selection)
   {
   case IDC_RECTANGLE:
      shapename = _T("Rectangle");
      break;

   case IDC_ROUND_RECTANGLE:
      shapename = _T("Round Rectangle");
      break;

   case IDC_ELLIPSE:
      shapename = _T("Ellipse");
      break;
   }

   str.Format(_T("Shape to be created is %s"), shapename);
}

CPropertyPage::OnWizardNext

이 멤버 함수는 사용자가 마법사에서 다음 단추를 선택할 때 프레임워크에서 호출됩니다.

virtual LRESULT OnWizardNext();

Return Value

0이면 자동으로 다음 페이지로 이동됩니다. 페이지가 변경되지 않도록 하려면 -1입니다. 다음 페이지가 아닌 다른 페이지로 이동하려면 표시할 대화 상자의 식별자를 반환합니다.

설명

이 멤버 함수를 재정의하여 다음 단추를 누를 때 사용자가 수행해야 하는 작업을 지정합니다.

마법사 유형 속성 시트를 만드는 방법에 대한 자세한 내용은 다음을 참조하세요 CPropertySheet::SetWizardMode.

예시

// The Next button is selected from the propertysheet. Show the 
// second page of the propertysheet ONLY if a non-zero value is 
// entered to the Number edit control of the CStylePage. Otherwise
// display a message to the user and stay on the current page.

LRESULT CStylePage::OnWizardNext()
{
   // Get the number from the edit control
   int num = GetDlgItemInt(IDC_NUMOBJECTS);

   if (num == 0)
   {
      // Display a message to the user
      AfxMessageBox(_T("Supply a non-zero number on the edit control"), MB_OK);

      // Stay on the current page
      return -1;
   }

   // CPropertyPage::OnWizardNext returns zero and causes
   // the property sheet to display the next page
   return CPropertyPage::OnWizardNext();
}

CPropertyPage::QuerySiblings

이 멤버 함수를 호출하여 속성 시트의 각 페이지에 메시지를 전달합니다.

LRESULT QuerySiblings(
    WPARAM wParam,
    LPARAM lParam);

매개 변수

wParam
추가 메시지 종속 정보를 지정합니다.

lParam
추가 메시지 종속 정보를 지정합니다.

Return Value

속성 시트에 있는 페이지의 0이 아닌 값이거나, 모든 페이지가 0 값을 반환하는 경우 0입니다.

설명

페이지가 0이 아닌 값을 반환하는 경우 속성 시트는 메시지를 후속 페이지로 보내지 않습니다.

예시

// Validate the value entered in the Number edit control. If its 
// value is not a natural number, request CPropertySheet (i.e. parent
// window of the page) to send a PSM_QUERYSIBLINGS message to each
// LOADED page (a page won't be loaded in memory until it is shown).
// If one of the pages returns a nonzero value in response to the 
// PSM_QUERYSIBLINGS message, then inform the user and change the OK
// to Close and disable the Cancel button. CStylePage is a 
// CPropertyPage-derived class.
BOOL CStylePage::OnApply()
{
   int num = GetDlgItemInt(IDC_NUMOBJECTS);
   if (num <= 0)
   {
      if (QuerySiblings(num, 0L))
      {
         AfxMessageBox(_T("Invalid data is entered.  Choose Close ")
            _T("button to close the dialog."));
         CancelToClose();
      }
   }

   return CPropertyPage::OnApply();
}

 

// This is an example of trapping the PSM_QUERYSIBLINGS in one of
// the pages. CColorPage is a CPropertyPage-derived class.  Upon 
// receiving this message, wParam contains the value passed to 
// QuerySiblings() call. CColorPage will check this value and return
// FALSE only if the value is greater than 1.
ON_MESSAGE(PSM_QUERYSIBLINGS, &CColorPage::OnQuerySiblings)

 

LRESULT CColorPage::OnQuerySiblings(WPARAM wParam, LPARAM lParam)
{
   UNREFERENCED_PARAMETER(lParam);
   return (wParam <= 0);
}

CPropertyPage::SetModified

속성 페이지의 설정을 적절한 외부 개체에 적용해야 하는지 여부에 따라 지금 적용 단추를 사용하거나 사용하지 않도록 설정하려면 이 멤버 함수를 호출합니다.

void SetModified(BOOL bChanged = TRUE);

매개 변수

bChanged
TRUE 속성 페이지 설정이 마지막으로 적용된 이후 수정되었음을 나타내려면 FALSE 속성 페이지 설정이 적용되었거나 무시되어야 함을 나타내는 입니다.

설명

프레임워크는 "더티"인 페이지, 즉 사용자가 호출SetModified( TRUE )한 속성 페이지를 추적합니다. 페이지 중 하나를 호출 SetModified( TRUE ) 하는 경우 지금 적용 단추가 항상 사용하도록 설정됩니다. 지금 적용 단추는 페이지 중 하나를 호출 SetModified( FALSE ) 할 때 사용하지 않도록 설정되지만 다른 페이지가 "더티"인 경우에만 사용할 수 없습니다.

예시

// OnColorClicked() is a member function of CColorPage (a
// CPropertyPage-derived class). It is called whenever a radio button
// is selected on the page. Call SetModified() to enable the Apply 
// button whenever a new selection is made. m_Color is a member
// variable of CColorPage and it is to store the selected RGB color.
// Its entry in the message map looks like this:
// ON_CONTROL_RANGE(BN_CLICKED, IDC_BLACK, IDC_GREEN, CColorPage::OnColorClicked)
void CColorPage::OnColorClicked(UINT nCmdID)
{
   COLORREF color = m_Color;
   switch (nCmdID)
   {
   case IDC_RADIOBLACK:
      color = RGB(0, 0, 0);
      m_radioColor = crBlack;
      break;

   case IDC_RADIORED:
      color = RGB(255, 0, 0);
      m_radioColor = crRed;
      break;

   case IDC_RADIOGREEN:
      color = RGB(0, 255, 0);
      m_radioColor = crGreen;
      break;

   case IDC_RADIOBLUE:
      color = RGB(0, 0, 255);
      m_radioColor = crBlue;
      break;
   }

   if (color != m_Color)
   {
      m_Color = color;
      SetModified();    // Enable Apply Now button.
   }

   UpdateData(FALSE);
}

참고 항목

MFC 샘플 CMNCTRL1
MFC 샘플 CMNCTRL2
MFC 샘플 PROPDLG
MFC 샘플 SNAPVW
CDialog 클래스
계층 구조 차트
CPropertySheet 클래스