"Ann & Jason Edmeades" <us(a)edmeades.me.uk> wrote:
> Copy and store the dwTypeData of a menu item even for a ownerdraw item, and
> ensure the memory allocations/freeing occurs correctly
> + /* Just change ftype to string and see what text is stored */
> + memset(&info, 0x00, sizeof(info));
> + info.cbSize= sizeof(MENUITEMINFO);
> + info.fMask= MIIM_FTYPE; /* Set string type */
> + info.fType= MFT_STRING;
> + info.dwTypeData= (char *)0xdeadbeef;
> + SetMenuItemInfo( hmenu, 0, TRUE, &info );
> +
> + /* Did we keep the old dwTypeData? */
> + ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
> + ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
> +
> + /* Just change ftype to bitmap and back to ensure data isnt freed */
> + memset(&info, 0x00, sizeof(info));
> + info.cbSize= sizeof(MENUITEMINFO);
> + info.fMask= MIIM_FTYPE; /* Set as bitmap type */
> + info.fType= MFT_BITMAP;
> + info.dwTypeData= (char *)0xdeadbee2;
> + SetMenuItemInfo( hmenu, 0, TRUE, &info );
> + info.fType= MFT_OWNERDRAW; /* Set as ownerdraw type */
> + info.dwTypeData= (char *)0xdeadbee3;
> + SetMenuItemInfo( hmenu, 0, TRUE, &info );
You don't check SetMenuItemInfo return code after the above calls and I very
much suspect that they fail leading to the observed results.
--
Dmitry.