久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

MFC中單選框和復選框的選擇

 冰晨之心 2012-09-11
單選鈕用來表示一系列的互斥選項,,這些互斥項常常被分成若干個組,每組僅允許用戶選擇一個選項,;復選框與單選按鈕相象,不同之處是復選框代表多重選擇,用戶可以選擇一個或多個選項。
為了方便說明,我們假定創(chuàng)建了基于對話框的MFC應用程序,,第一個組框為"分數",內有四個單選按鈕:"100","90","80","70".ID分別為IDC_RADIO1,IDC_RADIO2,IDC_RADIO3,IDC_RADIO4;IDC_RADIO1的Group屬性為TRUE.第二個組框為"加權",內有四個復選按鈕:"10","9","8","7",ID分別為IDC_CHECK1,IDC_CHECK2,IDC_CHECK3,IDC_CHECK4;IDC_CHECK1的Group屬性為TRUE.
判斷哪個單選按鈕按下:第一種方式:給IDC_RADIO1關聯(lián)一個int型變量m_radio,首先調用UpdateData(TRUE);然后判斷IDC_RADIO1的值
                           switch(m_radio)
                            {
                                   case 0:
                                            MessageBox(_T("100"));
                                            break;
                                   case 1:
                                            MessageBox(_T("90"));
                                            break;
                                   case 2:
                                            MessageBox(_T("80"));
                                            break;
                                   case 3:
                                            MessageBox(_T("70"));
                                            break;
                            }
          第二種方式:
                            switch(GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO4))
                            {
                                   case IDC_RADIO1:
                                            MessageBox(_T("100"));
                                            break;
                                   case IDC_RADIO2:
                                            MessageBox(_T("90"));
                                            break;
                                   case IDC_RADIO3:
                                            MessageBox(_T("80"));
                                            break;
                                   case IDC_RADIO4:
                                            MessageBox(_T("70"));
                                            break;
                            }
判斷哪些復選按鈕按下:第一種方式:給IDC_CHECK1~IDC_CHECK4分別關聯(lián)一個BOOL型變量m_check1~m_check4,首先調用UpdateData(TRUE);然后判斷各個變量的值;
                              if(m_check1==TRUE)
                                         str+="10";
                              if(m_check2==TRUE)
                                         str+="9";
                              if(m_check3==TRUE)
                                         str+="8";
                              if(m_check4==TRUE)
                                         str+="7";
                              MessageBox(str);
         第二種方式:給IDC_CHECK1~IDC_CHECK4分別關聯(lián)一個CButton型變量m_check1~m_check4判斷各個變量的值;
                              if(m_check1.GetCheck()==1)
                                         str+="10";
                              if(m_check2.GetCheck()==1)
                                         str+="9";
                              if(m_check3.GetCheck()==1)
                                         str+="8";
                              if(m_check4.GetCheck()==1)
                                         str+="7";
                              MessageBox(str);
         第三種方式:利用GetDlgItem()函數
                              CButton *pBtn1=(CButton*)GetDlgItem(IDC_CHECK1);
                              CButton *pBtn3=(CButton*)GetDlgItem(IDC_CHECK2);
                              CButton *pBtn3=(CButton*)GetDlgItem(IDC_CHECK3);
                              CButton *pBtn4=(CButton*)GetDlgItem(IDC_CHECK4);
                              if(pBtn1->GetCheck()==1)
                              str+="10";
                              if(pBtn2->GetCheck()==1)
                              str+="9";
                              if(pBtn3->GetCheck()==1)
                              str+="8";
                              if(pBtn4->GetCheck()==1)
                              str+="7";
         第四種方法:利用IsDlgButtonChecked()函數
                              if(BST_CHECKED == IsDlgButtonChecked( IDC_CHECK1 ))
                                           str+="10";
                              if(BST_CHECKED == IsDlgButtonChecked( IDC_CHECK2 ))
                                           str+="9";
                              if(BST_CHECKED == IsDlgButtonChecked( IDC_CHECK3 ))
                                           str+="8";
                              if(BST_CHECKED == IsDlgButtonChecked( IDC_CHECK4 ))
                                           str+="7";
                              MessageBox(str);

                            

      



    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,,不代表本站觀點,。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,,謹防詐騙,。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報,。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多