找回密码
 加入
搜索
查看: 4090|回复: 10

[AU3基础] 紧急求助解决_GUICtrlIpAddress_Create问题

  [复制链接]
发表于 2010-11-5 03:26:16 | 显示全部楼层 |阅读模式
本帖最后由 ssjoe 于 2010-11-6 01:13 编辑

各位大虾们,请求帮忙解决以下的问题!
一、Input框能否只允许输入数字但不要提示,也不可以复制
二、在IP窗口为空时或者最前段和后段为空时按钮同时不可以,但输入正确的IP段后才可用
三、能在Input窗口输入大于255时IP窗口变灰色不可自填写IP,但小于255时IP窗口可以也可自行填写!
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
Opt("GUIOnEventMode", 1)
$flag = ""
$Form1 = GUICreate("Form1", 294, 85)
GUISetOnEvent($GUI_EVENT_CLOSE, "GetMain")
$Button1 = GUICtrlCreateButton("Button1", 190, 30, 80, 25, 0)
$Label1 = GUICtrlCreateLabel("", 58, 4, 60, 28)
$Input1 = GUICtrlCreateInput("", 10, 20, 169, 25)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 10, 50, 169, 25)
_GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
GUISetState()

GUICtrlSetOnEvent($Button1, "GetMain")
GUICtrlSetOnEvent($Input1,"GetMain")

GUIRegisterMsg($WM_NOTIFY, "CheckInput")
GUIRegisterMsg($WM_CTLCOLOREDIT, "CheckInput")
ControlFocus ( "Form1", "", $Input1)
While 1
        Sleep(1000)

WEnd

Func GetMain()

        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"",GUICtrlRead($Input1))
                        
        EndSwitch
                
EndFunc

Func CheckInput()

        $Select1 = GUICtrlRead($Input1)
        If $Select1 = "" Then
                If BitAND(GUICtrlGetState($Button1), $GUI_ENABLE) = $GUI_ENABLE Then
                        GUICtrlSetState($Button1, $GUI_DISABLE)
                        GUICtrlSetData($Label1, "")
                        _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
                EndIf

        Else
                If BitAND(GUICtrlGetState($Button1), $GUI_DISABLE) = $GUI_DISABLE Then
                        GUICtrlSetState($Button1, $GUI_ENABLE)
                EndIf
                If GUICtrlRead($Input1) <> $flag Then
                        if StringIsDigit($Select1) <> 1 then $Select1 = ""
                        if $Select1 <> "" And $Select1 <=254 then
                                GUICtrlSetData($Label1, GUICtrlRead($Input1))
                                _GUICtrlIpAddress_Set($IPAddress1, "192.168.0." & GUICtrlRead($Input1))
                        Else
                                GUICtrlSetData($Label1, "")
                                _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
                        Endif
                        $flag = GUICtrlRead($Input1)
                EndIf

        EndIf     
EndFunc
 楼主| 发表于 2010-11-5 20:03:48 | 显示全部楼层
怎么回事呢?怎么没人可以帮得到这个忙吗?是否无法解决这个问题啊?
 楼主| 发表于 2010-11-5 22:12:06 | 显示全部楼层
急啊。。。。那位大虾能帮上忙啊。。。
 楼主| 发表于 2010-11-6 01:22:39 | 显示全部楼层
那位老师可以帮忙解决一下吧。。。万分感谢!
发表于 2010-11-6 10:17:38 | 显示全部楼层
奇怪的设计需求。不要太过于的考虑界面了。
 楼主| 发表于 2010-11-6 21:39:52 | 显示全部楼层
我想应该是。。。因为没人会想出这样的问题。相信这个功能比较难现实吧。。。唉。。。
发表于 2010-11-7 02:18:08 | 显示全部楼层
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiEdit.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 294, 85)
GUISetOnEvent($GUI_EVENT_CLOSE, "GetMain")
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "GetMain")
$Button1 = GUICtrlCreateButton("Button1", 190, 30, 80, 25, 0)
GUICtrlSetOnEvent($Button1, "GetMain")
GUICtrlSetState($Button1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("", 58, 4, 60, 28)
$Input1 = GUICtrlCreateInput("", 10, 20, 169, 25)
GUICtrlSetLimit($Input1, 3) ;只能输入三个字符
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 10, 50, 169, 25)
_WinAPI_EnableWindow($IPAddress1, False)
_GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;注册WM_COMMAND消息
ControlFocus("Form1", "", $Input1)
GUISetState()

While 1
        Sleep(100)
WEnd

Func GetMain()
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0, "", GUICtrlRead($Input1))
                Case $GUI_EVENT_PRIMARYUP
                        _GUICtrlEdit_SetSel($Input1, 3, 3)
        EndSwitch
EndFunc   ;==>GetMain

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ;消息处理
        $nNotifyCode = BitShift($wParam, 16)
        $nID = BitAND($wParam, 0x000FFFF)
        Switch $nID
                Case $Input1
                        Switch $nNotifyCode
                                Case $EN_CHANGE
                                        $Select = GUICtrlRead($Input1)
                                        If StringIsDigit($Select) And $Select <> "" And $Select <= 254 Then
                                                _GUICtrlIpAddress_Set($IPAddress1, "192.168.0." & $Select)
                                                GUICtrlSetState($Button1, $GUI_ENABLE)
                                                _WinAPI_EnableWindow($IPAddress1, True)
                                        Else
                                                GUICtrlSetData($Input1, "")
                                                _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
                                                GUICtrlSetState($Button1, $GUI_DISABLE)
                                                _WinAPI_EnableWindow($IPAddress1, False)
                                        EndIf
                        EndSwitch
        EndSwitch
EndFunc   ;==>WM_COMMAND
 楼主| 发表于 2010-11-7 11:47:11 | 显示全部楼层
回复 7# 风行者

非常感谢,我要的就是这样,我不知道你是否同一人。不管如何。我也是感谢你的帮忙。

不知能否再帮忙解决一下这个问题呢?

在IP窗口为空时或者前段和后段为空时按钮同时不可用,但输入正确的IP段后才可用
例如:
在Input窗口输入1时,IP窗口自动获得的值是"192.168.0.1"这样是正常了,
但在Input窗口还等于1时,IP窗口修改了地址为:0.0.0.0、192.168.0.0、192.168.0.、0.168.0.1、.168.0.1时,按钮同时变灰色不可用。
但输入正确的IP地址,按钮才可以正常使用,能否再帮忙解决一下!

简单的说就是修改IP地址前段或后段为空或为0时按钮不可用!
 楼主| 发表于 2010-11-9 01:40:08 | 显示全部楼层
大虾们都去那了,问题是否很难解决,还是无法解决这个问题呢?
 楼主| 发表于 2010-11-27 19:19:52 | 显示全部楼层
还没有大虾能帮到忙啊?
发表于 2010-11-27 19:58:21 | 显示全部楼层
回复 8# ssjoe
7#不是已经给了个大致的模板了吗,条件自己修改呀,多加几条判断就行了
还有,你那个正确的ip指的是什么?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 16:27 , Processed in 0.081137 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表