Hi there.
I have another problem concerning onwer-drawn menus. What i do is the following:
Load a menu from a resource (all the items have the type MFT_STRING or MFT_SEPARATOR; they aren't set to owner-draw yet). when i got the menu handle, i change all menu items to owner drawn and set the item data to it's menu handle.
When i receive WM_MEASUREITEM, i use GetMenuItemInfo with the menu handle being the item data to receive the item's text (dwTypeData). when i received the item's string, i modify it and try to set the item's text to the new modified string using SetMenuItemInfo.
On WM_DRAWITEM i use GetMenuItemInfo again to receive the item's text to draw it later.

But my program always runs into an exception fault. Sometimes, i can open the menu once, but nothing is shown. when i open it again, the exception fault occurs. by the time, the first exception fault has occured, nothin works anymore.
my computer sometimes starts to beep in fixed intervals. i don't know, but this code must be harming the system very hard. but i don't know why.

My question is:
Could it be, that the menu item's text (dwTypeData) gets invalid after settings the item to owner drawn? i mean, at the beginning of the program, menu item's with strings have MFT_STRING and the string in dwTypeData. but when i set it to owner draw, does dwTypeData get lost or invalid or whatever? so if it gets lost, an attempt to write (and read???) would end in an exception faut crashing the whole system?

I could really need some help on this one please.
Or maybe someone can tell me about another good method about how to implement an owner drawn menu. i mean, maybe its not possible to load a menu with menu item strings from a resource and then changing the item types to owner drawn and trying to use the item's text.
Posted on 2002-01-17 06:20:47 by darester