Tasmania Posted October 9, 2007 Author Share Posted October 9, 2007 Ok ok, I give up. Anyone know how to select all text inside of a text box automatically? Link to comment Share on other sites More sharing options...
aslani Posted October 9, 2007 Share Posted October 9, 2007 Ok ok, I give up. Anyone know how to select all text inside of a text box automatically? $txt2pcbk = GUICtrlCreateInput("$0.00", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER)) GUICtrlSetState(-1,$GUI_FOCUS) [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Siao Posted October 9, 2007 Share Posted October 9, 2007 (edited) _GUICtrlEditSetSel If anyone knows of an easier way to do this, please let me know... I don't like the idea of going to edit boxes.Edit box and input box is the same kind of control.SetSel and other messages is the way to go. GuiRegisterMsg WM_COMMAND message to catch EN_UPDATE notifications, and work with teh control from there, sending messages to it, EM_GETSEL, EM_SETSEL, EM_REPLACESEL, etc. Not sure if all of them are UDF-ed, although it doesn't really matter.It should be doable, although it won't be very easy. Each action the user could possibly take has to be accounted for. Lets say, if the user types in non-digit chars, erase them; if the user types in third number after decimal point, erase it; if the user tries to erase decimal point, replace it (and possibly set selection to dollars); etc. etc... Edited October 9, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Tasmania Posted October 9, 2007 Author Share Posted October 9, 2007 Edit box and input box is the same kind of control.SetSel and other messages is the way to go. GuiRegisterMsg WM_COMMAND message to catch EN_UPDATE notifications, and work with teh control from there, sending messages to it, EM_GETSEL, EM_SETSEL, EM_REPLACESEL, etc. Not sure if all of them are UDF-ed, although it doesn't really matter.It should be doable, although it won't be very easy. Each action the user could possibly take has to be accounted for. Lets say, if the user types in non-digit chars, erase them; if the user types in third number after decimal point, erase it; if the user tries to erase decimal point, replace it (and possibly set selection to dollars); etc. etc...You lost me at EN_UPDATE, can you give a short example to work with?Thanks for the help Link to comment Share on other sites More sharing options...
Siao Posted October 9, 2007 Share Posted October 9, 2007 (edited) Ok, here's an example to build on... expandcollapse popup#include <GUIConstants.au3> #Include <GuiEdit.au3> Global Const $WM_COMMAND = 0x0111 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 300, 71, -1,-1) $Input1 = GUICtrlCreateInput("$0.00", 64, 16, 153, 21) _GUICtrlEditSetSel($Input1, 1, 2) $btn = GUICtrlCreateButton("OK", 100, 45, 100, 20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Input1 ; Case $btn ; Case $GUI_EVENT_PRIMARYDOWN $aCursor = GUIGetCursorInfo() If $aCursor[4] = $input1 Then DllCall("user32.dll","int","ReleaseCapture") $aSel = _GUICtrlEditGetSel($Input1) If Not IsArray($aSel) Then ContinueCase ;if clicked behind dec point, select cents, else select dollars: ;(if double-clicked, selects cents): If $aSel[2] >= StringInStr(GUICtrlRead($Input1), ".") Then _GUICtrlEditSetSel($Input1, StringInStr(GUICtrlRead($Input1), "."), StringLen(GUICtrlRead($Input1))) Else _GUICtrlEditSetSel($Input1, 1, StringInStr(GUICtrlRead($Input1), ".")-1) EndIf EndIf EndSwitch WEnd Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAnd($wParam, 0x0000FFFF) $hCtrl = $lParam Switch $nNotifyCode Case 0x400 ;EN_UPDATE $aSel = _GUICtrlEditGetSel($Input1) If Not IsArray($aSel) Then Return $GUI_RUNDEFMSG $sChar = StringMid(GUICtrlRead($Input1), $aSel[2], 1) ConsoleWrite("User typed: " & $sChar & @CRLF) Case 0x100 ;EN_SETFOCUS ; EndSwitch Return $GUI_RUNDEFMSG EndFunc Doesn't do any format checking yet, just reports what was typed. And also controls selection when user clicks on the control. Edited October 9, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Tasmania Posted October 9, 2007 Author Share Posted October 9, 2007 Thanks Siao, I greatly appreciate it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now