ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6
part 7
part 8
part 9


6 - Group Issues

While using CButtonGroup works out well, it has one serious disadvantage - you can't prototype the layout on the Form Editor, since the buttons must be children of the CButtonGroup, rather than the form.

To work around this problem, I've written a class to enhance the CRadioButton, called cpaRadioButton. Using this as a springboard you could easily write a class to provide for exclusive pushbuttons as well (or checkboxes, although if you want exclusive checkboxes you should use radio buttons, which are expected to be exclusive).

The class is derived from CRadioButton, and just adds a few changes:
  • We add a group id to each button, allowing only one button in each group to be down at a time.
  • We link all the buttons together, so they can handle class effects.
  • We intercept and process button down messages, to check for exclusivity.
We link all the classes together via two values - each object has a pointer to the next cpaRadioButton, and we have a single static pointer value for the class, as the start of the list. Using these pointers, we create a linked list of object pointers, allowing each button to check all other cpaRadioButton buttons.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice