Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Creating and grouping radio buttons

c_simple_widget_app_1_0 creates two grouped radio buttons. Radio buttons are grouped by setting the same model on each button.

The following procedure shows how c_simple_widget_app_CreateRadioButtons() creates and groups radio buttons :

  1. Call ISHELL_CreateInstance() twice, to create two radio buttons:
    if (AEE_SUCCESS != ISHELL_CreateInstance(pMe->piShell,
                AEECLSID_CRadioWidget, (void **)&pMe->piwRadio1)) {
       pMe->piwRadio1 = NULL;
       return FALSE;
    }
    
    if (AEE_SUCCESS != ISHELL_CreateInstance(pMe->piShell, 
                AEECLSID_CRadioWidget, (void **)&pMe->piwRadio2)) {
       pMe->piwRadio2 = NULL;
       return FALSE;
    }

    Note that creating a radio button creates a small circle on the screen that can be selected or unselected. Labels for the radio buttons must be created separately.

  2. Create a model to group the radio buttons. For example:
    if (AEE_SUCCESS != (ISHELL_CreateInstance(pMe->piShell,
                AEECLSID_CModel, (void**)&piRadioGroupModel))) {
        return FALSE;
    }
  3. Set the model on each radio button, as follows:
    if (AEE_SUCCESS != IWidget_SetViewModel(pMe->piwRadio1,
                piRadioGroupModel)) {
        return FALSE;
    }
    
    if (AEE_SUCCESS != IWidget_SetViewModel(pMe->piwRadio2,
                piRadioGroupModel)) {
        return FALSE;
    }