Jump to content

suggest about guiipaddress


netegg
 Share

Recommended Posts

I've made an example for an MAC-input-control.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $aMAC

$Form1 = GUICreate("Test")
GUISetOnEvent(-3, 'Form1Close')
$aMAC = _GuiCtrlCreateMAC(20, 20)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While 1
    Sleep(100)
WEnd

Func Form1Close()
    Exit
EndFunc


Func _GuiCtrlCreateMAC($iLeft, $iTop, $iWidth=185, $iHeight=21, $iBorder=1)
    Local $width = ($iWidth - 5*$iBorder)/6
    Local $aInput[6], $x = $iLeft
    For $i = 0 To 5
        $aInput[$i] = GUICtrlCreateInput('', $x, $iTop, $width, $iHeight, 1)
        $x += $width +$iBorder
    Next
    Return $aInput
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    If BitShift($iwParam, 16) = 0x300 Then
        For $i = 0 To 5
            If GUICtrlGetHandle($aMAC[$i]) = $ilParam Then
                If StringLen(GUICtrlRead($aMAC[$i])) = 2 Then
                    If Not StringRegExp(GUICtrlRead($aMAC[$i]), '[a-fA-F0-9]{2}') Then
                        GUICtrlSetData($aMAC[$i], '')
                        Return $GUI_RUNDEFMSG
                    EndIf
                    If $i < 5 Then
                        ControlFocus($hWnd, '', $aMAC[$i+1])
                    EndIf
                EndIf
            EndIf
        Next
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Best Regards BugFix  

Link to comment
Share on other sites

Small exmaple of how to get the Mac Address:

Replace:

Func Form1Close()
    Exit
EndFunc

With:

Func Form1Close()
Local $aMacAddress = ''
for $i = 0 to UBound($aMAC)-1
  $aMacAddress &= GuiCtrlRead($aMAC[$i])
Next
MsgBox(0,'',$aMacAddress)
    Exit
EndFunc
----[ SandyD ]---
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...