创建一个GUI IP地址控件
#Include <GuiIPAddress.au3>
_GUICtrlIpAddress_Create($hWnd, $iX, $iY[, $iWidth = 125[, $iHeight = 25[, $iStyles = 0x00000000[, $iExstyles = 0x00000000]]]])
$hWnd | 父窗口或属主窗口句柄 |
$iX | 控件水平位置 |
$iY | 控件垂直位置 |
$iWidth | [可选参数] 控件宽度 |
$iHeight | [可选参数] 控件高度 |
$iStyles | [可选参数] 控件样式: 强制 : $WS_CHILD, $WS_VISIBLE, $WS_TABSTOP |
$iExStyles | [可选参数] 控件扩展样式 |
成功: | 返回 IP 地址控件句柄 |
失败: | 返回 0 |
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <WindowsConstants.au3>
$Debug_IP = False ; Check ClassName being passed to IPAddress functions, set to True and use a handle to another control to see it work
Global $hIPAddress
_Main()
Func _Main()
Local $hgui
$hgui = GUICreate("IP Address Control Create Example", 400, 300)
$hIPAddress = _GUICtrlIpAddress_Create($hgui, 10, 10)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")
; Wait for user to close GUI
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iCode, $tNMHDR
Local $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hIPAddress
Switch $iCode
Case $IPN_FIELDCHANGED ; Sent when the user changes a field in the control or moves from one field to another
$tInfo = DllStructCreate($tagNMIPADDRESS, $ilParam)
_DebugPrint("$IPN_FIELDCHANGED" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
"-->Field:" & @TAB & DllStructGetData($tInfo, "Field") & @LF & _
"-->Value:" & @TAB & DllStructGetData($tInfo, "Value"))
; The return value is ignored
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint