I'm trying to make an owner-draw menu in C++ and I'm having a lot of trouble. I'm using MFC's CMenu class and I'm trying InsertMenu();
mymenu->InsertMenu(0, MF_BYPOSITION|MF_OWNERDRAW, ID_RED, "Red");
After doing this, my OnDrawItem function retrieves a DRAWITEMSTRUCT as one of it's argumens and the structure contains a variable called itemData, which is a unsigned integer that contains the fourth parameter of InsertMenu. In my OnDrawItem, I do:
CString data = (LPCTSTR) lpdis->itemData; (lpdis is the DRAWITEMSTRUCT structure).
this works fine if I implement InsertMenu() like above, but when I fill InsertMenu with the fourth parameter being a variable that contains the string I want it to be, it doesn't work. Basically, I need figuring out why this works:
mymenu->InsertMenu(0, MF_BYPOSITION|MF_OWNERDRAW, ID_RED, "Red");
and not this:
CString red = "red";
mymenu->InsertMenu(0, MF_BYPOSITION|MF_OWNERDRAW, ID_RED, red);
If you have any hints or suggestions, please help me.