首页 > 代码库 > CIPAddressCtrl IP控件

CIPAddressCtrl IP控件

 CIPAddressCtrl 属性

 CIPAddressCtrl 成员函数

 成员函数代码测试

 

一、CIPAddressCtrl Class Members

IsBlank

Determines if all fields in the IP Address Control are empty.

ClearAddress

Clears the contents of the IP Address Control.

GetAddress

Retrieves the address values for all four fields in the IP Address Control.

SetAddress

Sets the address values for all four fields in the IP Address Control.

SetFieldFocus

Sets the keyboard focus to the specified field in the IP Address Control.

SetFieldRange

Sets the range in the specified field in the IP Address Control.

 

二、代码测试

// CDialog_IPAdress 消息处理程序

 

void CDialog_IPAdress::OnBnClickedButton1()

{

       // TODO: 在此添加控件通知处理程序代码

       BOOL r=m_ip.IsBlank();

       TRACE("%d \n",r);

}

 

void CDialog_IPAdress::OnBnClickedButton3()

{

       // TODO: 在此添加控件通知处理程序代码

       m_ip.ClearAddress();

}

 

void CDialog_IPAdress::OnBnClickedButton2()

{

       // TODO: 在此添加控件通知处理程序代码

       BYTE i1,i2,i3,i4;

       DWORD d;

       BYTE* pd=(BYTE*)&d;

//     m_ip.GetAddress(i1,i2,i3,i4);

      

 

       m_ip.GetAddress(d);

       i4=*pd++;

       i3=*pd++;

       i2=*pd++;

       i1=*pd;

       TRACE("i1=%d,i2=%d,i3=%d,i4=%d \n",i1,i2,i3,i4);

}

 

void CDialog_IPAdress::OnBnClickedButton4()

{

       // TODO: 在此添加控件通知处理程序代码

       m_ip.SetAddress(192,168,0,1);

       //m_ip.SetAddress(0x11223344);

}

 

void CDialog_IPAdress::OnBnClickedButton5()

{

       // TODO: 在此添加控件通知处理程序代码

       static int f=0;

        if (f>3)

        {

               f=0;

        }

       m_ip.SetFieldFocus(f++);

}

 

void CDialog_IPAdress::OnBnClickedButton6()

{

       // TODO: 在此添加控件通知处理程序代码

       //192.168.0.1- 192.168.0.100

        

       m_ip.SetFieldRange(0,192,192);

       m_ip.SetFieldRange(1,168,168);

       m_ip.SetFieldRange(2,0,0);

       m_ip.SetFieldRange(3,1,100);

}