I have a form with about 50 buttons on it. They have all been sub classed into a CJingleButton class. Now when a user clicks on a certain button (not a CJingleButton one) I need to run a method on all 50 buttons. So instead of writing out 50 calls, is there a neat way to put this into some sort of loop?
eg,
1 2 3 4
for (int i=0; i < 50; i++)
{
jingleButton[i].SomeFunction();
}
I did find a function in MFC called EnumChildWindows but this will only pass you the handle to the window, I then am unsure how to know whether this is a button (CButton), a JingleButton (CJingleButton) and how to get the class for the button so I can execute the method.
One way is to maintain a collection of these object. If the collection is called jingleButton, you can call your code above when you want them to do something.