You can set different values for each item as item data, then just get the item data using LB_GETITEMDATA message and switch it:
Code:
//while setting up the list
int item_index;
item_index = SendMessage(hCntrl, LB_ADDSTRING, 0, (LPARAM)"Open file");
SendMessage(hCntrl, LB_SETITEMDATA, (WPARAM)item_index, (LPARAM)MAKELPARAM(OPEN_FILE, 0));
item_index = SendMessage(hCntrl, LB_ADDSTRING, 0, (LPARAM)"Save file");
SendMessage(hCntrl, LB_SETITEMDATA, (WPARAM)item_index, (LPARAM)MAKELPARAM(SAVE_FILE, 0));
//and then to respond to action messages
switch(LOWORD(SendMessage(hCntrl, LB_GETITEMDATA, (WPARAM)nSelection, 0))) {
case OPEN_FILE: {
call_to_open_file();
}
break;
case SAVE_FILE: {
call_to_save_file();
}
break;
}
Of course you will have to declare previously OPEN_FILE and SAVE_FILE (macro or enum). If you have also a standard menu you can set the list item values with the same menu item values, so instead of switch the selected item value you can simulate a menu click sending a WM_COMMAND and the list item value that will correspond to the same action on the standard menu.
Hope that halps
Niara