MFC 控件用法

1:IP Control

变量CIPAddressCtrl m_iAddr

关联DDX_Control(pDX,IDC_IPADDRESS1,m_iAddr);

设置地址:m_iAddr.SetAddress(127,0,0,1);

读地址:BYTE nField0, nField1,nField2,nField3;

m_iAddr.GetAddress(nField0,nField1,nField2,nField3);

2: Radio-button Control

变量 int m_nRadioButton;

关联DDX_Radio(pDX,IDC_RADIO2,m_nRadioButton);

设置check状态 ((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(1);

使用UpdateData()后,点选的radio索引将会写入m_nRadioButton中。

下面是radio分组的方法,http://blog.csdn.net/c_cyoxi/article/details/23868979#comments

分组

将radio1、radio2、radio3分为1组,radio4、radio5分为另一组;

方法:设置  radio1  的 属性:  group、tabstop、auto均为true

设置  radio2 的 属性: group设为false, tabstop、auto均为true

设置  radio3  的 属性:group设为false,  tabstop、auto均为true

设置  radio4  的 属性:  group、tabstop、auto均为true

设置  radio5  的 属性:  group设为false,tabstop、auto均为true

 按CTRL+D,保证同一组内的radio的tab序号是连续的;调整tab序号的方式是:鼠标点击数字,比如先点3,然后点7,则3和7会交换,即radio1变为7,radio5变为3;

  关联int型变量   注意:只需将group属性为true的radio1关联,radio2和radio3无需关联;  同样,radio4需关联,radio5无需关联

完成后,在窗体头文件中可以看到

构造函数:

 默认第一个radio被选中,即radio1被选中

设置radio1的事件

设置radio2和radio3的点击事件函数 和 radio1 相同

事件代码:

注意:updatedata(true) 不能少; 它的作用是 将radio的状态值更新给关联的变量,即m_radiobtngroup1;

3:

原文地址:https://www.cnblogs.com/hgwang/p/6272797.html