#18 Custom statusbar and CmdBar crash

open
None
5
2004-11-03
2004-08-05
Bjarke Viksøe
No

Adding a ownerdrawn statusbar-item to a project with a
CommandBar causes random crashes.

It crashes in:
WTL::CCommandBarCtrlImpl::_MenuItemData::IsCmdBarM
enuItem() line 193 + 19 bytes
WTL::CCommandBarCtrlImpl::OnDrawItem(unsigned int
43, unsigned int 43, long
1236648, int & 1) line 1397 + 16 bytes
WTL::CCommandBarCtrlImpl::OnParentDrawItem
(unsigned int 43, unsigned int 59393,
long 1236648, int & 1) line 1579

The problem seems to be that the CmdBar traps
WM_DRAWITEM in the parent and does the following
check to discover if the item is owned by the CmdBar:

lpDIS->CtlType == ODT_MENU
&& pmd != NULL
&& pmd->IsCmdBarMenuItem()

Unfortunately the ownerdrawn statusbar is documented
NOT to use the CtlType, so in random cases it may just
have the value of 1 and cause the IsCmdBarMenuItem()
following to crash.

A check on HWND (lpDIS->hwndItem) is suggested as
solution.

Problem originally discovered by: satishkumr

Discussion

    • assigned_to: nobody --> nenadstefanovic