Hi all. I am trying to add a "Recent Files" addition to my Files Menu. Below is some code (just a test). Could some one tell me what I am doing wrong. I am trying to replace the menu names with the names of files. If you run the code you will understand what I am trying to do.

The first is the obvious one: once the Recent Files menu is modified, it stops actually triggering the "menu clicked" option in LB.

Another issue is that all the items created have the submenu caret on them, making it look like it's a submenu, not a clickable item.

Both are caused by improperly modifying the menus.

What you need to know to understand the first issue is that all menu items(not submenu placeholders) have individual internal numeric identifiers.

It's those identifiers that let LB know which one of those was clicked.

You're accidentally overwriting all of those to the same value(the handle value of the hRecent submenu), which isn't tied to anything, so nothing happens when it's clicked.

You need to preserve those identifiers when modifying the menu.

The second issue is also caused by improperly modifying the menu. In this case, not using the proper flags.

The reason they're showing up like that is because they all have the MF_POPUP flag applied to them.

You need to only apply the MF_POPUP flag when modifying the Recent Files menu item; it shouldn't be there for the actual menu items. Instead, the submenu handle should be replaced with the original numeric ID of the menu item.

This requires a couple of additional subroutines/functions to get working. See the modified code below.