bebeto90 Posted January 28, 2012 Posted January 28, 2012 Hi all, I need help with GUICtrlCreateInput. I need a user to either browse or type the location of a file on the same GUICtrlCreateInput field ... I am real close ... however if you look at the $GUI_button_browse button ... I try and give GUICtrlCreateInput a new value ... and what I am getting is 2 GUICtrlCreateInput fields in the same place ... what is worse is that if I click on the field the original blank field is activated and the the one with the path that I just browsed for is behind the blank field. Any suggestions how I can disable every think except the $GUI_button_select after the user browses ... or make the GUICtrlCreateInput with no value inactive after browsing.Please help many thanks. bebeto90 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;Create Window $Form1 = GUICreate("File Browser", 615, 438, 192, 124) $GUI_button_browse = GUICtrlCreateButton("Browse", 16, 24, 65, 33) $GUI_input = GUICtrlCreateInput("", 96, 30, 425, 21) $GUI_button_select = GUICtrlCreateButton("Select", 536, 24, 65, 33) $filebrowser = GUICtrlCreatePic("C:\Users\Public\Pictures\Sample Pictures\Desert.jpg", 16, 72, 585, 353) GUISetState(@SW_SHOW) ;Define Buttons While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_button_browse $message = "Select file to convert" $var = FileOpenDialog($message, @WindowsDir & "", "File (*.txt)", 1 + 4) If @error Then MsgBox(4096, "", "No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) MsgBox(4096, "", "You chose " & $var) $GUI_input = $var $GUI_input = GUICtrlCreateInput($var, 96, 30, 425, 21) EndIf Case $GUI_button_select $GUI_input_read = GUICtrlRead($GUI_input) If $GUI_input_read = "" Then MsgBox(4096, "", "No File(s) chosen") Else MsgBox(4096, "", "You chose " & $GUI_input_read) EndIf EndSwitch WEnd
Command3r Posted January 28, 2012 Posted January 28, 2012 is that what you need? expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;Create Window $Form1 = GUICreate("File Browser", 615, 438, 192, 124) $GUI_button_browse = GUICtrlCreateButton("Browse", 16, 24, 65, 33) $GUI_input = GUICtrlCreateInput("", 96, 30, 425, 21) $GUI_button_select = GUICtrlCreateButton("Select", 536, 24, 65, 33) ;~ $filebrowser = GUICtrlCreatePic("C:UsersPublicPicturesSample PicturesDesert.jpg", 16, 72, 585, 353) ; i dont know what do you want here. GUISetState(@SW_SHOW) ;Define Buttons While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_button_browse $message = "Select file to convert" $var = FileOpenDialog($message, @WindowsDir & "", "File (*.txt)", 1 + 4) If @error Then MsgBox(4096, "", "No File(s) chosen") ;~ Else ;~ $var = StringReplace($var, "|", @CRLF) ;~ MsgBox(4096, "", "You chose " & $var) ;~ $GUI_input = $var ;~ $GUI_input = GUICtrlCreateInput($var, 96, 30, 425, 21) EndIf GUICtrlSetData($Gui_Input, $var ) ; this to set what you choosed in browsing to Gui_Input. MsgBox(4096, "", "You choose " & $var) ; this saying what you have choosed. Case $GUI_button_select $GUI_input_read = GUICtrlRead($GUI_input) If $GUI_input_read = "" Then MsgBox(4096, "", "No File(s) chosen") Else MsgBox(4096, "", "You chose " & $GUI_input_read) EndIf EndSwitch WEnd [font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting. [font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color] [font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]
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