Click here to Skip to main content
11,928,403 members (51,319 online)
Rate this:
Please Sign up or sign in to vote.
See more: MFC VisualC++
I am going to develop mfc dialogue based application in which one scenario there is 3 radio buttons; whenever user click on the 3rd radio button, some controls on the dialog should be disable!!! How can I do that??
Posted 10-Jan-13 21:17pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Add BN_CLICKED handlers for all radio buttons to detect state changings. From within the handler, enable or disable dependant controls according to the button states. With your scenario, one function can handle it all:
// Handler function declared in header as 
//  afx_msg void OnBnClickedRadio();

void CMyDialog::OnBnClickedRadio()
    // Enable controls if radio button 3 is not checked
    CButton *pRadio3 = (CButton*)GetDlgItem(IDC_RBTN_3);
    BOOL bEnable = (BST_CHECKED != pRadio3->GetCheck());
    // Access control by ID
    // Access control by member var

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100