⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apicommctlinternetaddress.cls

📁 几个不错的VB例子
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ApiCommCtlInternetAddress"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

' ##MODULE_DESCRIPTION This class provides methods and properties for manipulating _
instances of the "Internet Address" windows custom control

Private m_hwnd As Long

Private Const IPN_FIRST = -860
Public Enum enIPAddressNotificationMessages
    IPN_FIELDCHANGED = -860
End Enum

Public Enum enIPAddressMessages
    IPM_CLEARADDRESS = 1124 ' ##  no parameters
    IPM_SETADDRESS = 1125 ' ##  lparam = TCP/IP address
    IPM_GETADDRESS = 1126 ' ##  lresult = # of non black fields.  lparam = LPDWORD for TCP/IP address
    IPM_SETRANGE = 1127 ' ##  wparam = field, lparam = range
    IPM_SETFOCUS = 1128 ' ##  wparam = field
    IPM_ISBLANK = 1129 ' ##  no parameters
End Enum

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Type NMIPADDRESS
    NMHDR_hwndFrom As Long
    NMHDR_idfrom As Long
    NMHDR_code As Long
    iField As Long
    iValue As Long
End Type

Public Enum enIPAddressFields
    IPAF_FIRST = 1
    IPAF_SECOND = 2
    IPAF_THIRD = 3
    IPAF_FOURTH = 4
End Enum

Public Property Get Blank() As Boolean

Dim lret As Long

lret = SendMessage(m_hwnd, IPM_ISBLANK, 0, ByVal 0&)
If Err.LastDllError > 0 Then
    ReportError Err.LastDllError, "ApiCommCtlInternetAddress:Clear", GetLastSystemError
End If
Blank = CBool(lret)

End Property

Public Property Get ClassName() As String

    ClassName = "SysIPAddress32"
    
End Property

Public Sub Clear()

Dim lret As Long

lret = SendMessage(m_hwnd, IPM_CLEARADDRESS, 0, ByVal 0&)
If Err.LastDllError > 0 Then
    ReportError Err.LastDllError, "ApiCommCtlInternetAddress:Clear", GetLastSystemError
End If

End Sub

Public Property Get hwnd() As Long

    hwnd = m_hwnd
    
End Property

Public Property Let hwnd(ByVal newHwnd As Long)

    If newHwnd <> m_hwnd Then
        m_hwnd = newHwnd
    End If
    
End Property

Public Property Let IPAddress(ByVal newAddress As Long)

Dim lret As Long

lret = SendMessage(m_hwnd, IPM_SETADDRESS, 0, ByVal newAddress)
If Err.LastDllError > 0 Then
    ReportError Err.LastDllError, "ApiCommCtlInternetAddress:IPAddress", GetLastSystemError
End If

End Property

Public Property Get IPAddress() As Long

Dim lret As Long
Dim lAddress As Long

lret = SendMessage(m_hwnd, IPM_GETADDRESS, 0, lAddress)
If Err.LastDllError > 0 Then
    ReportError Err.LastDllError, "ApiCommCtlInternetAddress:IPAddress", GetLastSystemError
End If
IPAddress = lAddress

End Property

Public Sub SetFieldFocus(ByVal WhichField As enIPAddressFields)

Dim lret As Long

lret = SendMessage(m_hwnd, IPM_SETFOCUS, WhichField, ByVal 0&)
If Err.LastDllError > 0 Then
    ReportError Err.LastDllError, "ApiCommCtlInternetAddress:SetFieldFocus", GetLastSystemError
End If

End Sub

Public Sub SetRange(ByVal WhichField As enIPAddressFields, ByVal Lower As Byte, ByVal Upper As Byte)

Dim lret As Long
Dim lRange As Long

lRange = APIDispenser.MakeInt(Lower, Upper)

lret = SendMessage(m_hwnd, IPM_SETFOCUS, WhichField, ByVal lRange)
If Err.LastDllError > 0 Then
    ReportError Err.LastDllError, "ApiCommCtlInternetAddress:SetFieldFocus", GetLastSystemError
End If

End Sub


Private Sub Class_Initialize()

'\\ make sure the common controls class is initialised
Call APIDispenser.InitCommonControls(ICC_INTERNET_CLASSES)

End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -