1

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

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

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 类的代码:

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 );
4

1 回答 1

1

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

BOOL bResult   = CPropertySheet::OnInitDialog();
m_bModeless    =  FALSE;  //Change to TRUE to fix the problem.
m_nFlags      &=  ~WF_CONTINUEMODAL;
于 2015-03-16T14:17:04.640 回答