15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


SC_CLOSE: MF_GRAYED - BUG?

Jeffrey Smith -- wyvern@msn.com
Thursday, September 12, 1996

Environment: VC++4.2/MFC Win95

I'm using MDI and preventing its views from being closed but I still want to 
enable min/max capability. 
So, in a view's frame class' ActivateFrame() I get its menu then:
	menu->EnableMenuItem( SC_CLOSE,  MF_BYCOMMAND | MF_GRAYED )

Problem:
This works great, except when the view is maximized. The close button moves up 
to the MDI frame keeping
the grayed out look but now closes the view if the user clicks on it. Yikes!

Workaround:
The short answer is: add ON_WM_CLOSE in the frame's message map then override 
OnClose() to do nothing.
This does what I wanted. It prevents the view from being closed.

Appeal for help
Has anyone seen this behavior before? Is it a bug? Is there an easier way or a 
better solution to prevent the
user from closing views?

Many thanks,
Jeff Smith



Vincent Mascart -- 100425.1337@compuserve.com
Sunday, September 15, 1996

>From: 	"Jeffrey Smith"
>Sent: 	vendredi 13 septembre 1996 10:18
>To: 	"MFC List - Submit"
>Subject: 	SC_CLOSE: MF_GRAYED - BUG?

>Environment: VC++4.2/MFC Win95
>
>I'm using MDI and preventing its views from being closed but I still want to 
>enable min/max capability. 
>So, in a view's frame class' ActivateFrame() I get its menu then:
>	menu->EnableMenuItem( SC_CLOSE,  MF_BYCOMMAND | MF_GRAYED )
>
>Problem:
>This works great, except when the view is maximized. The close button moves up 
>to the MDI frame keeping
>the grayed out look but now closes the view if the user clicks on it. Yikes!

You should consider disabling the menu item in OnInitialUpdate() of your view
with

GetParentFrame()->GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_BYCOMMAND |
MF_GRAYED) );

Vincent Mascart
100425.1337@compuserve.com





| Вернуться в корень Архива |