What’s wrong with this code part 24 (From an MSDN article)?
I ran into this bug earlier today and realized that it’d make an awesome “What’s wrong with this code”.
I started pulling together a test app when I realized that this MSDN magazine article contains sample code that perfectly exhibits the bug:
CRect rectangle; VERIFY(m_splitButton.GetWindowRect( &rectangle)); TPMPARAMS params = { sizeof(TPMPARAMS) }; params.rcExclude = rectangle; CMenuHandle menu = m_menu.GetSubMenu(0); VERIFY(menu.TrackPopupMenuEx(TPM_LEFTBUTTON, rectangle.left, rectangle.bottom, m_hWnd, ¶ms));
There’s not much to the code – it’s from the handler for the BCN_DROPDOWN notification message. And it’s got a very nasty subtle bug in it.
So what’s the bug?
Edit: s/nasty/subtle/