Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Question about radio button in RibbonBar Collapse All
Subject Author Date
Roongrit Charoensupkul Jun 28, 2007 - 7:26 AM


I want a button which has a radio box in front of it. This means that user can select option from radio box and when user press on text area of this button, it will bring to another callback function. How can I do that? I check the CMainFrame::_InitRibbonNode_View_ShowHide() method in the RibbonBar sample, and change __ECTN_TBB_RADIO_BOX style instead. But it seems the text area will behave the same when user click on the radio box.

Roongrit Charoensupkul Jun 28, 2007 - 7:27 AM

Do I have to create a CExtRibbonNodeGroup instance and insert two CExtRibbonNode instances, and let one show only radio box without text and another one show normal button?

Technical Support Jun 28, 2007 - 11:58 AM

The ribbon control supports push buttons, radio buttons and check box buttons. These buttons look differently but have exactly the same behavior. We guess you should simply use a radio button and a push button next to it. Please tell us why you need such non-standard radio button behavior?

Roongrit Charoensupkul Jun 28, 2007 - 9:47 PM

I find out how to implement this. Here is the code.

CExtRibbonNode* CreateRadioButton()
    CExtRibbonNode * pNodeRadio =
        new CExtRibbonNode( CUICommandSystem::Instance().ReserveCommandId(this),
        _T("") );
    pNodeRadio->ModifyFlags( __ECTN_TBB_RADIO_BOX );

    return pNodeRadio;

CExtRibbonNode* CreateNormailButton(const wstring& label)
    CExtRibbonNode* pButton =
        new CExtRibbonNode(CUICommandSystem::Instance().ReserveCommandId(this),


    return pButton;

void CRibbonRadioButton::Create(CExtRibbonNodeGroup* pParent)
    CExtRibbonNodeGroup* pRibbonRadioAndButton = new CExtRibbonNodeToolGroup(135);
    // Add radio button    
    pRibbonRadioAndButton->InsertNode(NULL, CreateRadioButton());

    // Add normal button
    CExtRibbonNodeToolGroup* pNodeNormalWrapper = new CExtRibbonNodeToolGroup(135);
    pRibbonRadioAndButton->InsertNode(NULL, pNodeNormalWrapper);

    pNodeNormalWrapper->InsertNode(NULL, CreateNormalButton(m_name));

    pParent->InsertNode(NULL, pRibbonRadioAndButton);

But the size of the buttons are different depend on text on the button. Are there the way to make it the same size? If I want the push button not to show its borders (rebar style), how to do that?


Technical Support Jun 29, 2007 - 12:26 PM

The size of a push button is determined by its content.

You are using a CExtRibbonNodeToolGroup group node as a container for two other nodes: radio button node and push button node in the CRibbonRadioButton::Create() method. That is why the push buttons become painted as tool buttons. You should not use tool button groups in your case. Just create six button nodes as children of one group node in the following order: 3 radio button nodes and then 3 push button nodes. In this case all the push buttons will have the background of their group node and the problem will gone.

Roongrit Charoensupkul Jul 5, 2007 - 9:52 AM

I cannot create the controls in this way. Because the number of button can be change on runtime, so I can’t hard code to create only the radio buttons before the push buttons. Any suggestion?

Technical Support Jul 5, 2007 - 12:29 PM

You can easily create the layout we mentioned above. Here is one column of buttons where X-radio and Y-push:


The creation order is: X1, X2, X3, Y1, Y2, Y3.

A bit more complex layout:

X1Y1 X4Y4 X7Y7
X2Y2 X5Y5 X8Y8
X3Y3 X6Y6

The creation order is: X1, X2, X3, Y1, Y2, Y3, X4, X5, X6, Y4, Y5, Y6, X7, X8, Y7, Y8.

You should simply create all buttons 3 by 3. In each group you should create 3 radio buttons and then 3 push buttons. If you have a dynamic number of radio/push button pairs, the last group may contain 1 or 2 pairs