mo_shaojie 发表于 2010-9-6 21:58:24

创建一个input控件.

如何创建$Box=GuiCtrlCreateinput($tex,200,$JG,190,20)
使它会显示$tex的内容文字,但用鼠标点击,这个控件显示的文字会自动消失的?
我这个显示得很清楚,用鼠标点击那些字不会自动消失,要删掉才行的.

lixiaolong 发表于 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

minghui 发表于 2010-9-7 09:34:59

回复 2# lixiaolong

试了一下,当用户手动输入后,就失去作用了

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 == $Input_1) Then GUICtrlSetData($Input_1, "")
                EndIf
EndFunc   ;==>mouseCHK

minghui 发表于 2010-9-7 20:44:04

学习了,很好...谢谢共享
页: [1]
查看完整版本: 创建一个input控件.