You probably want to handle kEventClassCommand/kEventProcessCommand, and use the command id from the menu item.
HICommand command;
GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL,
sizeof( HICommand ), NULL, &command );
switch (command.commandID) {
case 1:
... etc ...
Note that the commandID is one of the parameters to AppendMenuItemTextWithCFString
; that's how you can give each item a unique commandID as you generate the menu. commandID's are conventionally 4-char codes (like 'open' or 'save'), but there's no reason you couldn't use simple ints for your dynamically-generated commands.
David Gelhar
2010-05-11 12:36:45