求MFC中IP地址控件类 CIPAddressCtrl 定义及各函数 代码
展开全部
1)通过代码手动添加: addrinfo *aiList = NULL; char aHost[MAX_MFC中的IP地址控件是由CIPAddressCtrl类封装的。你可以研究一下他的成员函数。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
展开全部
在头文件夹下有,MFC的源代码都是公布了的。
追问
搜了下安装目录找到了,但MFC类文件具体是 怎么分布的啊
追答
这个没仔细研究,层次太复杂了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
class CIPAddressCtrl : public CWnd
{
DECLARE_DYNAMIC(CIPAddressCtrl)
public:
// Constructors
CIPAddressCtrl();
// Generic creator
virtual BOOL Create(_In_ DWORD dwStyle, _In_ const RECT& rect, _In_ CWnd* pParentWnd, _In_ UINT nID);
// Generic creator allowing extended style bits
virtual BOOL CreateEx(_In_ DWORD dwExStyle, _In_ DWORD dwStyle, _In_ const RECT& rect,
_In_ CWnd* pParentWnd, _In_ UINT nID);
// Attributes
// Determines if all fields in the IP address control are blank.
BOOL IsBlank() const;
// Clears the contents of the IP address control.
void ClearAddress();
// Retrieves the address values for all four fields in the IP address control.
int GetAddress(_Out_ BYTE& nField0, _Out_ BYTE& nField1, _Out_ BYTE& nField2, _Out_ BYTE& nField3) const;
int GetAddress(_Out_ DWORD& dwAddress) const;
// Sets the address values for all four fields in the IP address control.
void SetAddress(_In_ DWORD dwAddress);
void SetAddress(_In_ BYTE nField0, _In_ BYTE nField1, _In_ BYTE nField2, _In_ BYTE nField3);
// Sets the keyboard focus to the specified field in the IP address control.
void SetFieldFocus(_In_ WORD nField);
// Sets the valid range for the specified field in the IP address control.
void SetFieldRange(_In_ int nField, _In_ BYTE nLower, _In_ BYTE nUpper);
// Implementation
public:
virtual ~CIPAddressCtrl();
};
_AFXCMN_INLINE CIPAddressCtrl::CIPAddressCtrl()
{ }
_AFXCMN_INLINE void CIPAddressCtrl::ClearAddress()
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_CLEARADDRESS, 0, 0L); }
_AFXCMN_INLINE BOOL CIPAddressCtrl::IsBlank() const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, IPM_ISBLANK, 0, 0L); }
_AFXCMN_INLINE int CIPAddressCtrl::GetAddress(DWORD& dwAddress) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM) &dwAddress); }
_AFXCMN_INLINE void CIPAddressCtrl::SetAddress(DWORD dwAddress)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, (LPARAM) dwAddress); }
_AFXCMN_INLINE void CIPAddressCtrl::SetAddress(BYTE nField0, BYTE nField1, BYTE nField2, BYTE nField3)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, (LPARAM) MAKEIPADDRESS(nField0, nField1, nField2, nField3)); }
_AFXCMN_INLINE void CIPAddressCtrl::SetFieldFocus(WORD nField)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETFOCUS, (WPARAM) nField, 0); }
_AFXCMN_INLINE void CIPAddressCtrl::SetFieldRange(int nField, BYTE nLower, BYTE nUpper)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETRANGE, (WPARAM) nField, MAKEIPRANGE(nLower, nUpper)); }
CIPAddressCtrl::~CIPAddressCtrl()
{
DestroyWindow();
}
BOOL CIPAddressCtrl::Create(DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd, UINT nID)
{
// initialize common controls
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_INTERNET_REG));
// the IP Address Control must be a child
ASSERT(dwStyle & WS_CHILD);
CWnd* pWnd = this;
return pWnd->Create(WC_IPADDRESS, NULL, dwStyle, rect, pParentWnd, nID);
}
BOOL CIPAddressCtrl::CreateEx(DWORD dwExStyle, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID)
{
BOOL bRet = Create(dwStyle, rect, pParentWnd, nID);
if (bRet && dwExStyle != 0)
{
bRet = ModifyStyleEx(0, dwExStyle);
}
return bRet;
}
int CIPAddressCtrl::GetAddress(BYTE& nField0, BYTE& nField1, BYTE& nField2, BYTE& nField3) const
{
ASSERT(::IsWindow(m_hWnd));
DWORD dwAddress;
LRESULT nRetVal = ::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM) &dwAddress);
nField0 = (BYTE) FIRST_IPADDRESS(dwAddress);
nField1 = (BYTE) SECOND_IPADDRESS(dwAddress);
nField2 = (BYTE) THIRD_IPADDRESS(dwAddress);
nField3 = (BYTE) FOURTH_IPADDRESS(dwAddress);
//IA64: only four fields in an IP address, so an int won't overflow
return int(nRetVal);
}
{
DECLARE_DYNAMIC(CIPAddressCtrl)
public:
// Constructors
CIPAddressCtrl();
// Generic creator
virtual BOOL Create(_In_ DWORD dwStyle, _In_ const RECT& rect, _In_ CWnd* pParentWnd, _In_ UINT nID);
// Generic creator allowing extended style bits
virtual BOOL CreateEx(_In_ DWORD dwExStyle, _In_ DWORD dwStyle, _In_ const RECT& rect,
_In_ CWnd* pParentWnd, _In_ UINT nID);
// Attributes
// Determines if all fields in the IP address control are blank.
BOOL IsBlank() const;
// Clears the contents of the IP address control.
void ClearAddress();
// Retrieves the address values for all four fields in the IP address control.
int GetAddress(_Out_ BYTE& nField0, _Out_ BYTE& nField1, _Out_ BYTE& nField2, _Out_ BYTE& nField3) const;
int GetAddress(_Out_ DWORD& dwAddress) const;
// Sets the address values for all four fields in the IP address control.
void SetAddress(_In_ DWORD dwAddress);
void SetAddress(_In_ BYTE nField0, _In_ BYTE nField1, _In_ BYTE nField2, _In_ BYTE nField3);
// Sets the keyboard focus to the specified field in the IP address control.
void SetFieldFocus(_In_ WORD nField);
// Sets the valid range for the specified field in the IP address control.
void SetFieldRange(_In_ int nField, _In_ BYTE nLower, _In_ BYTE nUpper);
// Implementation
public:
virtual ~CIPAddressCtrl();
};
_AFXCMN_INLINE CIPAddressCtrl::CIPAddressCtrl()
{ }
_AFXCMN_INLINE void CIPAddressCtrl::ClearAddress()
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_CLEARADDRESS, 0, 0L); }
_AFXCMN_INLINE BOOL CIPAddressCtrl::IsBlank() const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, IPM_ISBLANK, 0, 0L); }
_AFXCMN_INLINE int CIPAddressCtrl::GetAddress(DWORD& dwAddress) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM) &dwAddress); }
_AFXCMN_INLINE void CIPAddressCtrl::SetAddress(DWORD dwAddress)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, (LPARAM) dwAddress); }
_AFXCMN_INLINE void CIPAddressCtrl::SetAddress(BYTE nField0, BYTE nField1, BYTE nField2, BYTE nField3)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, (LPARAM) MAKEIPADDRESS(nField0, nField1, nField2, nField3)); }
_AFXCMN_INLINE void CIPAddressCtrl::SetFieldFocus(WORD nField)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETFOCUS, (WPARAM) nField, 0); }
_AFXCMN_INLINE void CIPAddressCtrl::SetFieldRange(int nField, BYTE nLower, BYTE nUpper)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, IPM_SETRANGE, (WPARAM) nField, MAKEIPRANGE(nLower, nUpper)); }
CIPAddressCtrl::~CIPAddressCtrl()
{
DestroyWindow();
}
BOOL CIPAddressCtrl::Create(DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd, UINT nID)
{
// initialize common controls
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_INTERNET_REG));
// the IP Address Control must be a child
ASSERT(dwStyle & WS_CHILD);
CWnd* pWnd = this;
return pWnd->Create(WC_IPADDRESS, NULL, dwStyle, rect, pParentWnd, nID);
}
BOOL CIPAddressCtrl::CreateEx(DWORD dwExStyle, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID)
{
BOOL bRet = Create(dwStyle, rect, pParentWnd, nID);
if (bRet && dwExStyle != 0)
{
bRet = ModifyStyleEx(0, dwExStyle);
}
return bRet;
}
int CIPAddressCtrl::GetAddress(BYTE& nField0, BYTE& nField1, BYTE& nField2, BYTE& nField3) const
{
ASSERT(::IsWindow(m_hWnd));
DWORD dwAddress;
LRESULT nRetVal = ::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM) &dwAddress);
nField0 = (BYTE) FIRST_IPADDRESS(dwAddress);
nField1 = (BYTE) SECOND_IPADDRESS(dwAddress);
nField2 = (BYTE) THIRD_IPADDRESS(dwAddress);
nField3 = (BYTE) FOURTH_IPADDRESS(dwAddress);
//IA64: only four fields in an IP address, so an int won't overflow
return int(nRetVal);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询