Jump to content
Sign in to follow this  
Underdogger

When I click the textfield....

Recommended Posts

Underdogger

Here is the test code..

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$myForm = GUICreate("", 308, 154, 441, 261)
$R1 = GUICtrlCreateRadio("CHOOSE1", 32, 24, 113, 17)
GUICtrlSetState($R1, $GUI_CHECKED)
$R2 = GUICtrlCreateRadio("CHOOSE2", 32, 80, 113, 17)
$I1 = GUICtrlCreateInput("", 152, 24, 121, 21)
$I2 = GUICtrlCreateInput("", 152, 80, 121, 21)
$b1 = GUICtrlCreateButton("Start", 120, 120, 75, 25)
GUISetState(@SW_SHOW)


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $b1
If GUICtrlRead($R1) = $GUI_CHECKED Then
MsgBox("", "Tip", GUICtrlRead($I1))
ElseIf GUICtrlRead($R2) = $GUI_CHECKED Then
MsgBox("", "Tip", GUICtrlRead($I2))
EndIf
EndSwitch
WEnd

If I click the 2nd text field,I hope the 2nd radio will be selected at the same time...No need to select the radio again after I click the text field...

Thanks so much.. :rambo:

Edited by Underdogger

Share this post


Link to post
Share on other sites
Underdogger

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $EDIT_DEF_ITEMS[1][2] = [[0, 0]];;>>>>>>gray string
$myForm = GUICreate("", 308, 154, 441, 261)
$R1 = GUICtrlCreateRadio("CHOOSE1", 32, 24, 113, 17)
GUICtrlSetState($R1, $GUI_CHECKED)
$R2 = GUICtrlCreateRadio("CHOOSE2", 32, 80, 113, 17)

$I1 = GUICtrlCreateInput("", 152, 24, 121, 21)
$I2 = GUICtrlCreateInput("", 152, 80, 121, 21)

_GUIEditSetDefault ($I2, "Input something...");>>>>>placeholder hint
$b1 = GUICtrlCreateButton("Start", 120, 120, 75, 25)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $b1
If GUICtrlRead($R1) = $GUI_CHECKED Then
MsgBox("", "Tip", GUICtrlRead($I1))
ElseIf GUICtrlRead($R2) = $GUI_CHECKED Then
MsgBox("", "Tip", GUICtrlRead($I2))
EndIf
EndSwitch
WEnd

Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)

If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $I2 Then
If GUICtrlRead($I2) <> "" Then
GUICtrlSetState($R2, $GUI_CHECKED)
EndIf
EndIf

EndFunc

;;---------placeholder hint Start---------------------
Func _GUIEditSetDefault($hEdit, $sDef)
If $hEdit = 0 Then Return SetError(1, 0, 0)

If $EDIT_DEF_ITEMS[0][0] = 0 Then GUIRegisterMsg(0x0111, "EDIT_DEF_WM_COMMAND")

If GUICtrlRead($hEdit) = "" Then
GUICtrlSetColor($hEdit, 0x444444)
GUICtrlSetData($hEdit, $sDef)
EndIf

ReDim $EDIT_DEF_ITEMS[UBound($EDIT_DEF_ITEMS) + 1][2]
$EDIT_DEF_ITEMS[UBound($EDIT_DEF_ITEMS) - 1][0] = $hEdit
$EDIT_DEF_ITEMS[UBound($EDIT_DEF_ITEMS) - 1][1] = $sDef

Return 1
EndFunc

Func EDIT_DEF_WM_COMMAND($hWnd, $msgID, $wParam, $lParam)
Local $n = EDIT_DEF_GETINDEX(BitAND ($wParam, 0xFFFF))
If $n = -1 Then Return "GUI_RUNDEFMSG"

Local $nMsg = BitShift($wParam, 16)
If $nMsg = 256 Then
If (GUICtrlRead($EDIT_DEF_ITEMS[$n][0]) == $EDIT_DEF_ITEMS[$n][1]) Then
GUICtrlSetColor($EDIT_DEF_ITEMS[$n][0], 0x000000)
GUICtrlSetData($EDIT_DEF_ITEMS[$n][0], "")
EndIf
ElseIf $nMsg = 512 Then
If GUICtrlRead($EDIT_DEF_ITEMS[$n][0]) = "" Then
GUICtrlSetColor($EDIT_DEF_ITEMS[$n][0], 0x444444)
GUICtrlSetData($EDIT_DEF_ITEMS[$n][0], $EDIT_DEF_ITEMS[$n][1])
EndIf
EndIf
EndFunc

Func EDIT_DEF_GETINDEX($hEdit)
For $i = 1 to UBound($EDIT_DEF_ITEMS) - 1
If $EDIT_DEF_ITEMS[$i][0] = $hEdit Then Return $i
Next
Return -1
EndFunc
;;---------placeholder hint End---------------------

I've solved this problem...but new problem appeared...

when I type in the second text field...the placeholder hint will not disappear...

Edited by Underdogger

Share this post


Link to post
Share on other sites
PhoenixXL

I dunno what is a placeholder

can tell what your aim is ?


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
PhoenixXL

I guess what you want is CueBanner

wait i will give you an example

Here it is

#include <EditConstants.au3>

GUICreate( "" )
GUICtrlCreateInput( "", 10, 10 )
GUICtrlCreateInput( "", 10, 40 ) ; Set CueBanner to this Input only
GUISetState()

Local $iShowonfocus = False
;Lets set the CueBanner
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, $iShowonfocus, "This is the PlaceHolder Text" )

While GUIGetMsg()<>-3
Sleep(10)
WEnd
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
Underdogger

I guess what you want is CueBanner

wait i will give you an example

Here it is

#include <EditConstants.au3>

GUICreate( "" )
GUICtrlCreateInput( "", 10, 10 )
GUICtrlCreateInput( "", 10, 40 ) ; Set CueBanner to this Input only
GUISetState()

Local $iShowonfocus = False
;Lets set the CueBanner
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, $iShowonfocus, "This is the PlaceHolder Text" )

While GUIGetMsg()<>-3
Sleep(10)
WEnd

PhoenixXL YOU are a very nice person! Regard!!

Share this post


Link to post
Share on other sites
Underdogger

Yes!!The whole topic gonna be solved~ :thumbsup:

Elson

Share this post


Link to post
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
Sign in to follow this  

×