UDF > GUI > GuiIPAddress >


_GUICtrlIpAddress_Create

Crée un contrôle IPAddress qui gère une adresse IP (Internet Protocol)

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_Create ( $hWnd, $iX, $iY [, $iWidth = 125 [, $iHeight = 25 [, $iStyles = 0x00000000 [, $iExstyles = 0x00000000]]]] )

Paramètres

$hWnd Handle du parent ou de la fenêtre propriétaire
$iX Position horizontale du contrôle
$iY Position verticale du contrôle
$iWidth [optionnel] Largeur du contrôle
$iHeight [optionnel] Hauteur du contrôle
$iStyles [optionnel] Styles du contrôle:
Forçés: $WS_CHILD, $WS_VISIBLE, $WS_TABSTOP
$iExStyles [optionnel] Styles étendus du contrôle. Ils correspondent aux constantes standards $WS_EX_*. Consultez Table des styles étendus.

Valeur de retour

Succès: Retourne le handle du contrôle IPAddress.
Échec: Retourne 0.

Remarque

Le contrôle IPAddress contient l'adresse d'un ordinateur sur un réseau IP.

En relation

_GUICtrlIpAddress_Destroy

Exemple

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <WindowsConstants.au3>

Global $g_hIPAddress

Example()

Func Example()
    Local $hGui

    $hGui = GUICreate("IP Address Control Create Example", 400, 300)
    $g_hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    _GUICtrlIpAddress_Set($g_hIPAddress, "24.168.2.128")

    ; Attend que l'utilisateur ferme la GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR
    Local $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    If $hWndFrom = $g_hIPAddress Then
        If $iCode = $IPN_FIELDCHANGED Then 
            ; Envoyé quand l'utilisateur modifie un champ du contrôle ou se déplace d'un champ à un autre
            $tInfo = DllStructCreate($tagNMIPADDRESS, $lParam)
            _DebugPrint("$IPN_FIELDCHANGED" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                "-->Field:" & @TAB & DllStructGetData($tInfo, "Field") & @CRLF & _
                "-->Value:" & @TAB & DllStructGetData($tInfo, "Value"))
            ; La valeur retournée est ignorée
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint