Could somebody help me with the following problem:
I have a modal CPropertySheet dialog. I need to add the minimize button to
it.
The command
CWnd::ModifyStyle( 0,WS_MINIMIZEBOX );
adds the button, but this button does not work
(nothing happens when I click on it).
I don't know how to add the minimize button which would work.
Thank you in advance.
Serguei Korolev.
Did you ever get this working? Anyway, you're on the right track. The second step is to add the
SC_MINIMIZE command to the system menu. Rather, you have to destroy the default system menu, make a
new copy of it (which will contain everything), and remove all the commands that you *don't* want,
but leave the SC_MINIMIZE command in this case. I don't recommend doing this unless your
CPropertySheet is the main window of a dialog-based app -- wierd things seem to result. And then
you'll probably want to add a handler for the WM_INITMENUPOP message too.
BOOL CMyPropertySheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
ModifyStyle(0, WS_MINIMIZEBOX);
GetSystemMenu(TRUE);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);
}
SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
return bResult;
}
void CMyPropertySheet::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CPropertySheet::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
if (pPopupMenu && bSysMenu)
{
if (IsIconic())
{
pPopupMenu->EnableMenuItem(SC_MOVE, MF_GRAYED);
pPopupMenu->EnableMenuItem(SC_RESTORE, MF_ENABLED);
pPopupMenu->EnableMenuItem(SC_MINIMIZE, MF_GRAYED);
pPopupMenu->SetDefaultItem(SC_RESTORE);
}
else
{
pPopupMenu->EnableMenuItem(SC_MOVE, MF_ENABLED);
pPopupMenu->EnableMenuItem(SC_RESTORE, MF_GRAYED);
pPopupMenu->EnableMenuItem(SC_MINIMIZE, MF_ENABLED);
pPopupMenu->SetDefaultItem(SC_CLOSE);
}
}
}
HTH,
Jeff...
--
Please post all follow-ups to the newsgroup only.
Serguei Korolev wrote in message <8ur0n6$ph2$1...@dragon.infopro.spb.su>...
This is really the main window of my application, so I needed this button.
Thank you very much !!! You have been very helpful.
Sincerely yours,
Serguei Korolev.
Jeff Partch <airb...@airmail.net> пишет в
сообщении:ONT1xMCUAHA.222@cppssbbsa03...
How can I make that the minimize button works ?
Thanks in advance.
Elias
Elias.