1
votes

I have a CPropertySheet with three tabs. I have a different CPropertyPage class for each tab. When my CPropertySheet is loaded with the debugger, the first page is always shown correctly. However, when I click on any of the other tabs, the CPropertyPage area becomes blank. Even if I click back on the first tab, the area is still empty. I am using Visual Studio, MFC, C++.

I am trying to find the proper way to handle the different tab clicks and have my tabs show correctly. This is the code to initialize my property sheet and it's pages:

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;

This is the code for my 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 );
1
If there is a display problem with the pages, it most likely is in the code for the actual page which you have not shown. Especially since you say that the first page displays correctly the first time.rrirower
Do you know if I need a special event I need in my pages? I am trying to understand how to use OnSetActive.Kyle Williamson
OnSetActive is only required when you'd like to augment/override the base processing when the page becomes active. You'd typically perform some extra processing that the page needs before it is displayed.rrirower
So the CPropertSheet should handle the page changes automatically? I have updated my code with the code of one of my simple pages.Kyle Williamson
The example page I added shows correctly if I make it my first page. With any tab clicks, everything is removed. Thanks @rrirowerKyle Williamson

1 Answers

1
votes

My problem was that I was setting m_bModeless to false,

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