09-10-2018 10:22 AM
I have a menu created in my UIR file. In the same UIR (or hypothetically another), I want to programmatically copy a menubar item to the other.
I'm not seeing a DuplicateMenuItem or similar function. Am I missing something? Surely there's a way to do this.
Solved! Go to Solution.
09-11-2018 09:40 AM
I don't see a function like that either. The only way I can see to do it is to manually read the name and callback function pointer of the source item (GetMenuBarAttribute) and use them to create a new target item (NewMenuItem).
09-11-2018 10:16 AM
Yeah, that's what I'll just have to do in this case. I hadn't thought of the reading the menu item label and callback. That's a nice solution, as I can continue creating the menu in the UIR but copy in code.
Only thing I can't find is how to read the icon of a menu item in order to copy it. There doesn't appear to be an attribute for attached images, probably because the IDE immediately encodes the image bitmap into the UIR. Bummer.
09-11-2018 10:20 AM
Perhaps ATTR_ITEM_BITMAP?
09-12-2018 12:49 PM - last edited on 10-10-2018 08:34 AM by Kristi_Martinez
Hmm, I'm getting negative bitmap ID numbers when calling:
GetMenuBarAttribute(mainMenu, menuItem, ATTR_ITEM_BITMAP, &image);
Other attributes of this menu item work, such as both ATTR_CALLBACK_FUNCTION_POINTER and ATTR_ITEM_NAME. As such, when I copy all of these to my new destination menu, I get the name of the item, its callback function, but no image.
There's a whole section in the help manual called "Using Bitmap Objects" but nothing there references menus specifically.
09-20-2018 09:59 AM
I haven't looked into why ATTR_ITEM_BITMAP doesn't work, but would calling LoadMenuBar on the new panel, followed by removing all the menu items that you don't need, be a feasible solution?
09-20-2018 10:03 AM
That could work. Give it a try.
10-10-2018 07:56 AM
I finally got around to working on this again. I found the solution to my bitmap problem. It was even easier than I realized.
It turns out that when a new menu is created, by default the ATTR_SHOW_IMAGES is disabled. So enabling that before checking for existence of a source menu bitmap then will show in the destination.