mfc CIPAddressCtrl控件

时间:2024-06-02 11:04:14
知识点:
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(,,,);
//m_ip.SetAddress(0x11223344);
} void CDialog_IPAdress::OnBnClickedButton5()
{
// TODO: 在此添加控件通知处理程序代码
static int f=;
if (f>)
{
f=;
}
m_ip.SetFieldFocus(f++);
} void CDialog_IPAdress::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
//192.168.0.1- 192.168.0.100 m_ip.SetFieldRange(,,);
m_ip.SetFieldRange(,,);
m_ip.SetFieldRange(,,);
m_ip.SetFieldRange(,,);
}