如何正确更改 CPropertySheet 上的选项卡

How to properly change tabs on CPropertySheet

我有一个包含三个选项卡的 CPropertySheet。每个选项卡都有不同的 CPropertyPage class。当使用调试器加载我的 CPropertySheet 时,第一页总是正确显示。但是,当我单击任何其他选项卡时,CPropertyPage 区域变为空白。即使我在第一个选项卡上单击返回,该区域仍然是空的。我正在使用 Visual Studio、MFC、C++。

我正在尝试找到正确的方法来处理不同的选项卡点击并正确显示我的选项卡。这是初始化我的 属性 sheet 及其页面的代码:

BOOL CSLIMOptCplusplusApp::InitInstance()
{
CWinApp::InitInstance();
SQLHENV m_1;
EnvGetHandle(m_1);

Login lgn;   //Creates a Login dialog for the user to enter credentials.
lgn.DoModal();

CImageSheet*      imagedlg = new CImageSheet( "Admin Options" );
CImageDisplay*    pageImageDisplay    = new CImageDisplay;
CImageDimensions* pageImageDimensions = new CImageDimensions;
ListOption*       pageListOption      = new ListOption;

ASSERT( imagedlg );
ASSERT( pageImageDisplay );
ASSERT( pageImageDimensions );  
ASSERT( pageListOption );

imagedlg->AddPage( pageListOption);
imagedlg->AddPage( pageImageDisplay );
imagedlg->AddPage( pageImageDimensions );

imagedlg->m_psh.dwFlags |= PSH_NOAPPLYNOW;  //Removes the default Apply button
imagedlg->Create();
imagedlg->ShowWindow( SW_SHOW );
m_pMainWnd = imagedlg;

这是我的 CPropertySheet 的代码 class:

BOOL CImageSheet::OnInitDialog()
{
CWnd* pOKButton = GetDlgItem( IDOK );
ASSERT( pOKButton );
pOKButton->ShowWindow( SW_HIDE );

CWnd* pCANCELButton = GetDlgItem( IDCANCEL );
ASSERT( pCANCELButton );
pCANCELButton->ShowWindow( SW_HIDE );

// Set Flags for property sheet
m_bModeless    =  TRUE;
m_nFlags      |=  WF_CONTINUEMODAL;


BOOL bResult   = CPropertySheet::OnInitDialog();
m_bModeless    =  FALSE;
m_nFlags      &=  ~WF_CONTINUEMODAL;

//Get button sizes and positions
CRect rect, tabrect;
GetDlgItem( IDOK )->GetWindowRect( rect );
GetTabControl()->GetWindowRect( tabrect );

ScreenToClient( rect );
ScreenToClient( tabrect );  

UpdateData( FALSE );

我的问题是我将 m_bModeless 设置为 false,

BOOL bResult   = CPropertySheet::OnInitDialog();
m_bModeless    =  FALSE;  //Change to TRUE to fix the problem.
m_nFlags      &=  ~WF_CONTINUEMODAL;