//---------------------------------------------------------------------------
#pragma hdrstop
#include "code__IPInput.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TIPInput::TIPInput(int _top,int _left,int _height,int _width,
HWND _ParentHandle,HINSTANCE _hinst)
{
m_handle = CreateWindow(WC_IPADDRESS,NULL,WS_CHILD|WS_VISIBLE,
_left,_top,_width,_height,_ParentHandle,0,_hinst,NULL);
}
//---------------------------------------------------------------------------
TIPInput::~TIPInput()
{
CloseHandle(m_handle);
}
//---------------------------------------------------------------------------
void TIPInput::SetText(UnicodeString _ip)
{
u_long u = ntohl(inet_addr(AnsiString(_ip).c_str()));
SendMessage(m_handle,IPM_SETADDRESS,0,u);
}
//---------------------------------------------------------------------------
void TIPInput::SetIP(u_long _ip)
{
SendMessage(m_handle,IPM_SETADDRESS,0,_ip);
}
//---------------------------------------------------------------------------
UnicodeString TIPInput::GetText()
{
DWORD ip;
SendMessage(m_handle,IPM_GETADDRESS,0,(LPARAM)&ip);
return UnicodeString(FIRST_IPADDRESS(ip))+"."+UnicodeString(SECOND_IPADDRESS(ip))+"."+UnicodeString(THIRD_IPADDRESS(ip))+"."+UnicodeString(FOURTH_IPADDRESS(ip));
}
//---------------------------------------------------------------------------
u_long TIPInput::GetIP()
{
DWORD ip;
SendMessage(m_handle,IPM_GETADDRESS,0,(LPARAM)&ip);
return ip;
}
//---------------------------------------------------------------------------
void TIPInput::Clear()
{
SendMessage(m_handle,IPM_CLEARADDRESS,0,0);
}
//---------------------------------------------------------------------------
bool TIPInput::IsBlank()
{
return SendMessage(m_handle,IPM_ISBLANK,0,0);
}
//---------------------------------------------------------------------------
void TIPInput::SetActivedField(int index)
{
SendMessage(m_handle,IPM_SETFOCUS,index,0);
}
//---------------------------------------------------------------------------
void TIPInput::SetFieldRange(int index,Byte high,Byte low)
{
SendMessage(m_handle,IPM_SETRANGE,index,MAKEIPRANGE(high,low));
}
//---------------------------------------------------------------------------
评论2
最新资源