We help IT Professionals succeed at work.

Removing Tabs from CPropertySheet / CPropertyPages

MMathieson
MMathieson asked
on
Medium Priority
740 Views
Last Modified: 2013-11-20
Hi,
I've been trying to write a simple program using MFC where I've embedded a CPropertySheet into a Dialog Box and have added two CPropertyPages to the property sheet.  The two pages have tabs at the top of the sheet which I want to remove.  How do I go about removing the tabs?

Cheers,
Matt
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Hi MMathieson,

please explain what you really want, i.e. how you want to switch between the two
pages without the tabs? Do you want a wizard? Or do you want your program
to switch automatically? If so I would suggest to not use propertysheet at all but
simply create to child dialogs (with WS_CHILD and DS_CONTROL), create them
as modeless dialogs inside a modal parent-dialog and show that one you need.

ZOPPO

Author

Commented:
Zoppo,
Thanks for your interest.  Ok, here's what I'm trying to do.  I've got a CPropertySheet embedded in a Dialog.  I am trying to create a Wizard style interface but I don't want to use the standard Wizard provided by the CPropertySheet, i.e. SetWizardMode()  I have already tried using a set of dialogs but couldn't get the TAB key to work correctly hence why I've gone to the CPropertySheet.  I have already tried to change the style and extended style of the sheet and page but have not had any luck.

Cheers,
Matt.
CERTIFIED EXPERT

Commented:
Hi again,

though I would still suggest using simple child dialogs. You should get the TAB key
working by setting the DS_CONTROL for the child dialog.

If you want I can send you a small dialog-test-app with two child dialogs which I think
are working ok (send me a mail to zoppo@cdsgmbh.de so I can reply to you)

ZOPPO

Author

Commented:
Zoppo,
No need for the example as I already have one.  By setting the "Control Parent" property for all of the dialogs, the tab key started to work.  QED.

Just out of curiosity, I would still like to know how to remove the tabs off a CPropertySheet / CPropertyPage.

Thanks for your help.
Matt.

Author

Commented:
Zoppo,
No need for the example as I already have one.  By setting the "Control Parent" property for all of the dialogs, the tab key started to work.  QED.

Just out of curiosity, I would still like to know how to remove the tabs off a CPropertySheet / CPropertyPage.

Thanks for your help.
Matt.
CERTIFIED EXPERT

Commented:
Sorry, but I have to leave office now ... I'll try this tomorrow ... I'm not sure if it's possible, but we'll see...

have a nice evening,

ZOPPO
CERTIFIED EXPERT
Commented:
Hi MMathieson,

the only way I found to remove the tabs is to use the property sheet in
wizard-mode and remove the buttons. This can be done by deriving a
new class from CPropertySheet, i.e. CMyPropSheet, and implement
the OnInitDialog like this:

BOOL CMyPropSheet::OnInitDialog()
{
 BOOL bResult = CPropertySheet::OnInitDialog();
     
 GetDlgItem( ID_WIZBACK )->ShowWindow( SW_HIDE );
 GetDlgItem( ID_WIZNEXT )->ShowWindow( SW_HIDE );

 return bResult;
}

Then, i.e. you could override the PreTranslateMessage like this to be
able to switch between the pages using F6 and SHIFT-F6:

BOOL CMyPropSheet::PreTranslateMessage(MSG* pMsg)
{
 if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F6 )    
 {
  int i = GetPageIndex( GetActivePage() );
  if ( GetKeyState( VK_SHIFT ) < 0 )
  {
   i--;
   if ( i < 0 )
    i = GetPageCount() - 1;
  }
  else
  {
   i++;
   if ( i >= GetPageCount() )
    i = 0;
  }
  SetActivePage( GetPage( i ) );
  return TRUE;
 }

 return CPropertySheet::PreTranslateMessage(pMsg);
}

ZOPPO