2009-06-18 62 views
0

我知道我可以爲一組單選按鈕創建一個整數變量,將其設置爲一個整數,然後調用UpdateData(FALSE)使窗口高亮顯示相應的無線電按鈕控制。但是,我想也許會使用CButton控件,但我不知道如何設置CButton狀態,以便檢查組的特定單選按鈕。 MFC甚至有可能這樣做嗎?提前致謝。MFC:突出顯示一組單選按鈕的CButton

回答

0

由於我只需要在啓動或重置狀態時設置狀態,我將CButton控件與CButton控件的相應ID標誌鏈接在一起,然後再將其打開。 CButton控件稍後可以包含其他值,因爲onclicked()處理程序用於我正確映射選定的單選按鈕值。

void UserControls::DoDataExchange(CDataExchange* pDX) 
{ 
    ... 
    // Mapping the integer variables to the Radio control for proper 
    // displaying 
    // not the id of the first radio button of the group for both of them 
    DDX_Control(pDX, IDC_NOBTL, nobCtrl);   
    DDX_Control(pDX, IDC_UIHARD, uiCtrl); 
    ... 
}