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

Developer

resources

Creating labels for radio buttons

After creating the two radio buttons, c_simple_widget_app_CreateRadioButtons() creates two static widgets for each button, as follows:

  1. Call ISHELL_CreateInstance() twice with the AEECLSID_CStaticWidget ClassID to create the two static widgets:
    if (AEE_SUCCESS != ISHELL_CreateInstance(pMe->piShell,
                AEECLSID_CStaticWidget, (void **)&pMe->piwRText1)) {
       pMe->piwRText1 = NULL;
       return FALSE;
    }
    
    if (AEE_SUCCESS != ISHELL_CreateInstance(pMe->piShell,
                AEECLSID_CStaticWidget, (void **)&pMe->piwRText2)) {
     		pMe->piwRText2 = NULL;
     		return FALSE;
    }
  2. Call c_simple_widget_app_SetText() for each widget, to set the text for each static widget:
    // specify text for label 1
    if (!c_simple_widget_app_SetText(pMe->piwRText1, RADIO1_TEXT)) {
        return FALSE;
    }
    
    // specify text for label 2
    if (!c_simple_widget_app_SetText(pMe->piwRText2, RADIO2_TEXT)) {
        return FALSE;
    }

    c_simple_widget_app_SetText() gets the model for the static widget and then sets the value of the static widget (the text), as follows:

    // get the value model for the static widget
    nErr = IWidget_GetModel(piWidget, AEEIID_IValueModel,
                (IModel**)(void*)&pValModel);
    
    if (AEE_SUCCESS == nErr) {
        // set the value of the static widget to the desired text
        IValueModel_SetValue(pValModel, (void*)pwszText,
                WSTRLEN(pwszText), NULL);
    
        // release the value model since it's no longer needed
        (void) IValueModel_Release(pValModel);
    }