I have a function that performs a specific action depending on the std::string value it receives.
Eg:
void performTaskOnStringValue(std::string);
Now I have a set of Ribbon Buttons (CMFCRibbonButton) that need to call this function by passing their respective text as values on button click.
I have mapped the id's of these buttons to a message map macro on_command with the button id's. All the buttons share one common id - Eg -
ID_RIBBON_BUTTON_ID
The message map is as follows
ON_COMMAND(ID_RIBBON_BUTTON_ID, &MyClass::performTaskOnStringValue);
How do I pass the button text as parameter to this function on ButtonClick?
You can't make the buttons do different operations when they all have the same ID. The command handler gets no indication of which button was pressed.
If you can assign consecutive IDs to the buttons you can use ON_COMMAND_RANGE instead. This will pass you the ID of the button, which you can pass to GetDlgItemText to get the text from the button.