CMFCMenuButton not showing dropdownlist in release

2019-08-31 02:10发布

问题:

I have a CMFCMenuButton on a CDialogBar that has a very strange behaviour: it shows its dropdown list in the Debug build but does not show it in the Release build.

Debug build:

Release build:

It seems that there is happening something wrong in the call of __super::OnShowMenu() of the OnShowMenu() method of my derived class.

To make thing worse, there is some configuration on my machine that is not stepping into the MFC feature pack methods ... I made everything to put this working and I could not get there.

Please help.

回答1:

Sorry, it was my mistake:

On my derived class OnShowMenu function, I had to replace:

pMyMenu= new CMenu;
ASSERT(pMyMenu->CreatePopupMenu());
this->m_hMenu= pMyMenu->GetSafeHmenu();

with this:

pMyMenu= new CMenu;
pMyMenu->CreatePopupMenu();
this->m_hMenu= pMyMenu->GetSafeHmenu();

Yes, the bug was caused by the ASSERT.