QA: How can I create a property sheet with menubar and minimize button?
Daniel Strigl (daniel.strigl@web.de), July 17, 2003.
Question
I am using a property sheet (CPropertySheet) in my dialog based MFC application.
How can I create a property sheet with accessible menubar and minimize button?
Answer
The answer is not very difficult. Just create your own class derived from CPropertySheet.
class CMyPropertySheet : public CPropertySheet
{
...
}
Inside the OnInitDialog message handler remove (hide) the OK button, so that the
minimze button will be visible and create your menubar. When you have created your
menubar you can load your toolbar from the application resources.
BOOL CMyPropertySheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
// TODO: Add your specialized code here
// Remove (hide) the OK button
SHDoneButton(m_hWnd, SHDB_HIDE);
// Create the command bar control
m_pWndEmptyCB = new CCeCommandBar;
ASSERT_VALID(m_pWndEmptyCB);
if (m_pWndEmptyCB != NULL)
{
m_pWndEmptyCB->CreateEx(this);
ASSERT(::IsWindow(m_pWndEmptyCB->m_hWnd));
// Load the toolbar
CCeCommandBar* pCommandBar = (CCeCommandBar*) m_pWndEmptyCB;
ASSERT_VALID(pCommandBar);
pCommandBar->LoadToolBar(IDR_OK_CANCEL);
pCommandBar->SetSizes(CSize(83 + 7, 16 + 6), CSize(83, 16));
}
return bResult;
}
After that you can add some message handlers for your menubar buttons.
BEGIN_MESSAGE_MAP(CMyPropertySheet, CPropertySheet)
//{{AFX_MSG_MAP(CMyPropertySheet)
ON_COMMAND(ID_OK, OnOk)
ON_COMMAND(ID_CANCEL, OnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyPropertySheet::OnOk()
{
// TODO: Add your command handler code here
if (GetActivePage()->UpdateData())
{
m_bOkToClose = TRUE;
EndDialog(IDOK);
}
}
void CMyPropertySheet::OnCancel()
{
// TODO: Add your command handler code here
m_bOkToClose = TRUE;
EndDialog(IDCANCEL);
}
Don't forget that the normal MFC implementation of CPropertySheet doesn't work with the
transcriber. So, for more information about this problem and how to fix it just take a look
at the following article:
QA: Why does not CPropertySheet work with transcriber?
Sample application
You can download a sample application
that illustrates a property sheet with minimize button and menubar.
Related resources:
-
http://www.pocketpcdn.com/sections/ui.html
Section: User Interface
-
http://www.pocketpcdn.com/articles/remove_x_button.html
QA: How to remove smart minimize (X) button from the taskbar?
-
http://www.pocketpcdn.com/articles/propertysheet_transcriber.html
QA: Why does not CPropertySheet work with transcriber?
-
http://www.pocketpcdn.com/articles/fullscreen_propertysheet.html
QA: How to use property sheets in full screen mode?
-
http://www.pocketpcdn.com/articles/dialogbar.html
QA: How can I use a command bar in a dialog?