BCGControlBar Pro for MFC
virtual void CBCGPCalculator::OnUserCommand ( UINT  uiCmd)
protectedvirtual

Called when the user presses a custom button.

If you have called SetAdditionalCommands() with a list of custom commands, you have to override OnUserCommand() in a derived class.

uiCmd contains a command ID which is assigned to a button. Command IDs are assigned automatically starting from CBCGPCalculator::idCommandUser and conform to the order of strings you passed in the string list when called SetAdditionalCommands().

Parameters
uiCmdSpecifies the command ID.

The code below enables calculator button with additional commands:

Copy
CStringList lstCommands;
lstCommands.AddTail("Sin");
lstCommands.AddTail("Cos");
lstCommands.AddTail("Tan");
SetAdditionalCommands(&lstCommands);

The code below shows how to implement OnUserCommand:

Copy
double dblVal = pCalculator->GetValue();
switch (uiCmd)
{
case CBCGPCalculator::idCommandUser: // Sin
dblVal = sin(dblVal);
break;
case CBCGPCalculator::idCommandUser + 1: // Cos
dblVal = cos(dblVal);
break;
case CBCGPCalculator::idCommandUser + 2: // Tan
dblVal = tan (dblVal);
break;
}