找回密码
 加入
搜索
查看: 2657|回复: 4

[AU3基础] 创建一个input控件.

[复制链接]
发表于 2010-9-6 21:58:24 | 显示全部楼层 |阅读模式
如何创建$Box[1]=GuiCtrlCreateinput($tex[2],200,$JG,190,20)
使它会显示$tex[2]的内容文字,但用鼠标点击,这个控件显示的文字会自动消失的?
我这个显示得很清楚,用鼠标点击那些字不会自动消失,要删掉才行的.
发表于 2010-9-7 03:29:13 | 显示全部楼层
这是我以前在网上看到的,请你参考
#include <GuiConstants.au3>

Global $MARk_1     = 0
Global $DEFAULTINPUTDATA_1   = "Click and type something here..."

Global $NONEAACTIVECOLOR     = 0x989898



$GUI = GUICreate("Check Inputs Demo", 280, 150)

$Input_1 = GUICtrlCreateInput($DEFAULTINPUTDATA_1, 15, 20, 250, 20)
GUICtrlSetColor(-1, $NONEAACTIVECOLOR)

$ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

ControlFocus($Gui, "", $ExitButton)


While 1
     _CheckInput($GUI, $Input_1, "Click and type something here...", $DEFAULTINPUTDATA_1, $MARK_1)
     Switch GUIGetMsg()
         Case $ExitButton, -3
             Exit
     EndSwitch
WEnd

Func _CheckInput($hWnd, $ID, $InputDefText, ByRef $DefaultInputData, ByRef $Mark)
     If $Mark = 0 And _IsFocused($hWnd, $ID) And $DefaultInputData = $InputDefText Then
         $Mark = 1
         GUICtrlSetData($ID, "")
         GUICtrlSetColor($ID, 0x000000)
         $DefaultInputData = ""
     EndIf
EndFunc

Func _IsFocused($hWnd, $nCID)
     Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-9-7 09:34:59 | 显示全部楼层
回复 2# lixiaolong

试了一下,当用户手动输入后,就失去作用了
发表于 2010-9-7 20:11:58 | 显示全部楼层
回复 3# minghui

我琢磨半天,终于解决了
#include <GuiConstants.au3>

$GUI = GUICreate("Check Inputs Demo", 280, 150)

$Input_1 = GUICtrlCreateInput("Click and type something here...", 15, 20, 250, 20)

$ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

ControlFocus($GUI, "", $ExitButton)

While 1
        $nMsg = GUIGetMsg()
        Select
                Case $nMsg = $GUI_EVENT_CLOSE
                        Exit
                Case $nMsg = $ExitButton
                        Exit
                Case $nMsg = $GUI_EVENT_PRIMARYDOWN
                        mouseCHK()
        EndSelect
WEnd

Func mouseCHK()
$pos = GUIGetCursorInfo()
                if $pos <> 0 then
                If ($pos[4] == $Input_1) Then GUICtrlSetData($Input_1, "")
                EndIf
EndFunc   ;==>mouseCHK
发表于 2010-9-7 20:44:04 | 显示全部楼层
学习了,很好...  谢谢共享
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 22:16 , Processed in 0.104283 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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