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

时间:2015-03-16 13:11:36

标签: c++ tabs mfc cpropertysheet

我有一个带有三个标签的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 );

感谢您的帮助!

编辑:

这是我希望展示的简单页面的代码。

// ImageDisplay.cpp : implementation file
//

#include "stdafx.h"
#include "SLIMOptCplusplus.h"
#include "ImageDisplay.h"
#include "afxdialogex.h"
#include "ListOption.h"

// CImageDisplay dialog

char g_emailProfile[255];

IMPLEMENT_DYNAMIC(CImageDisplay, CPropertyPage)

CImageDisplay::CImageDisplay()
: CPropertyPage(CImageDisplay::IDD)
, m_EmailProfile(_T(g_emailProfile))
{

}

CImageDisplay::~CImageDisplay()
{
}

void CImageDisplay::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
DDX_Text(pDX, TXTC_EMAIL_PROFILE, m_EmailProfile);
}


BEGIN_MESSAGE_MAP(CImageDisplay, CPropertyPage)
END_MESSAGE_MAP()


// CImageDisplay message handlers

1 个答案:

答案 0 :(得分:1)

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

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