Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CPropertySheet minimize button

71 views
Skip to first unread message

Serguei Korolev

unread,
Nov 14, 2000, 3:00:00 AM11/14/00
to
Hi !

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.


Serguei Korolev

unread,
Nov 14, 2000, 3:00:00 AM11/14/00
to

Serguei Korolev

unread,
Nov 14, 2000, 3:00:00 AM11/14/00
to

Jeff Partch

unread,
Nov 16, 2000, 3:00:00 AM11/16/00
to
Hi, Serguei!

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>...

Serguei Korolev

unread,
Nov 17, 2000, 3:00:00 AM11/17/00
to
Hi, Jeff !

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...

Elias Barcia Mejias

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to
Hi ,
I have the same problem that Serguei had, I had added the lines of code that Jeff wrote but I can not
make the minimize button works.
My PropertySheet is also the main window, the minimize button is added when OninitDialog is executed
but when I press it, nothing happens.

How can I make that the minimize button works ?

Thanks in advance.
Elias

Elias Barcia Mejias

unread,
Dec 11, 2000, 10:21:36 AM12/11/00
to
Hi!.
I have found the solution here.
http://codeguru.earthweb.com/propertysheet/upd_creating_cprop_appl.shtml.
And it is different than Jeff's solution.

Elias.

0 new messages