Problem with ON_UPDATE_CMD_UI & checking a menu item
Dave Wruck -- media119@mail.idt.net
Saturday, December 07, 1996
Environment: VC++ 1.52, Windows 3.1/NT 3.51
I have developed a CMDIChildWnd derived object that manages it's own menu
replacement with the parent frame. When the CMDIChildWnd object
initializes, it loads a copy of the main frame menu from the exe resources
as well as the pop-up menu dedicated to the child window. It then merges
the menus with an "InsertMenu" on the mainframe menu. The CMenu is then
detached from this new merged menu and the HMenu is stored in the child
object. When the child window is activated, it replaces the MDI parent's
menu with the
one it has constructed.
This all seems to work just fine. However, I have placed an
ON_UPDATE_COMMAND_UI macro in my message map to check or uncheck one of the
items in my merged sub-menu based on a value in the class. The mapping is
working correctly and the function is called when I pull down the "merged"
popup menu. However, when I call the "SetChecked" function on the pCmdUI
object, it doesn't have any effect on the menu item. I have verified the
item id and the index in the CCmdUI structure and I don't see any obvious
problems.
Also, I've stepped through the SetChecked function in the debugger through
the
CMenu "CheckMenuItem" function to no avail.
What the heck am I missing here?
Any help will be much appreciated,
David A. Wruck
Creative Media Software Corp.
media119@mail.idt.net
Dave Wruck -- media119@mail.idt.net
Tuesday, December 10, 1996
Just to give you an update, I solved this problem today by eliminating my
use of CMenu and instead used the straight Windows 3.1 API function calls
for inserting a menu. I suspect that the "GetSubMenu(0)" function of CMenu
was hosing up my menu handles somehow. Once I made the API calls,
everything worked just fine.
If anyone has any insight into why CMenu was rendering my inserted popup
unresponsive to the "SetChecked" funcion, I would appreciate the info.
----------
> From: Dave Wruck
> To: MFC Mailing List
> Subject: Problem with ON_UPDATE_CMD_UI & checking a menu item
> Date: Saturday, December 07, 1996 7:30 AM
>
> Environment: VC++ 1.52, Windows 3.1/NT 3.51
>
> I have developed a CMDIChildWnd derived object that manages it's own menu
> replacement with the parent frame. When the CMDIChildWnd object
> initializes, it loads a copy of the main frame menu from the exe
resources
> as well as the pop-up menu dedicated to the child window. It then merges
> the menus with an "InsertMenu" on the mainframe menu. The CMenu is then
> detached from this new merged menu and the HMenu is stored in the child
> object. When the child window is activated, it replaces the MDI parent's
> menu with the
> one it has constructed.
>
> This all seems to work just fine. However, I have placed an
> ON_UPDATE_COMMAND_UI macro in my message map to check or uncheck one of
the
> items in my merged sub-menu based on a value in the class. The mapping
is
> working correctly and the function is called when I pull down the
"merged"
> popup menu. However, when I call the "SetChecked" function on the pCmdUI
> object, it doesn't have any effect on the menu item. I have verified the
> item id and the index in the CCmdUI structure and I don't see any obvious
> problems.
>
> Also, I've stepped through the SetChecked function in the debugger
through
> the
> CMenu "CheckMenuItem" function to no avail.
>
> What the heck am I missing here?
>
> Any help will be much appreciated,
>
> David A. Wruck
> Creative Media Software Corp.
> media119@mail.idt.net
| Вернуться в корень Архива
|