2
votes

I have an old, old, VB6 legacy system to maintain. This system creates popup menus by calling CreatePopupMenu and InsertMenuItem. They now want the system to show dynamic color squares in these popup menu (= a color picker).

I am using the following code to create the menu items:

InsertMenuItem(hMenu, lItem, MF_BYPOSITION Or MF_OWNERDRAW, lpmii)

where lItem is the item index in hMenu, and lpmii is a MENUITEMINFO struct.

My problem is that the form in which this menu is created does not receive my WM_DRAWITEM message. I pass the window's hWnd in the call to TrackPopupMenuEx, and I subclass it using SetWindowLong.

What am I doing wrong?

1

1 Answers

4
votes

The third parameter to InsertMenuItem fByPosition is of type BOOL. It controls the meaning of uItem and cannot be used to enable owner-drawing of a menu item. To enable owner-drawing of a menu item you have to add the MIIM_FTYPE flag to MENUITEMINFO::fMask and specify the MFT_OWNERDRAW value for MENUITEMINFO::fType.

For additional information see Creating Owner-Drawn Menu Items.