创建一个input控件.
如何创建$Box=GuiCtrlCreateinput($tex,200,$JG,190,20)使它会显示$tex的内容文字,但用鼠标点击,这个控件显示的文字会自动消失的?
我这个显示得很清楚,用鼠标点击那些字不会自动消失,要删掉才行的. 这是我以前在网上看到的,请你参考#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 回复 2# lixiaolong
试了一下,当用户手动输入后,就失去作用了 回复 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 学习了,很好...谢谢共享
页:
[1]