vickerps Posted July 7, 2004 Share Posted July 7, 2004 (edited) Hi has anyone created a button that brings up an explorer window (like browse) to locate a file. which once found it puts the path to that file in a text box on the gui form. Edited July 8, 2004 by vickerps Link to comment Share on other sites More sharing options...
emmanuel Posted July 8, 2004 Share Posted July 8, 2004 why don't you just create a button that sets a variable with FileOpenDialog and the text field that reads that variable? "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
vickerps Posted July 9, 2004 Author Share Posted July 9, 2004 I knew there was somthing like fileOpenDialog. Thanks Been playing with it how do you refresh the GuiScreen so that it display the value of the varible in the Input box. I have this so far.. Opt("GUICoordMode", 1) Opt("GUINotifyMode", 1) GuiCreate($Customer, 392,243,-1, -1 , 0x04CF0000) WinActivate ( $Customer ) $OldDBPath = GUISetControl("input", $Data, 90, 10, 130, 25) GUISetControl("label", "OldDBPath", 20, 10, 60, 20) $Browse1 = GUISetControl("button", "Browse", 230, 10, 40, 25) GUISetControl("label", "NewDBPath", 20, 60, 60, 20) $NewDBPath = GUISetControl("input", "", 90, 60, 130, 25) $Apply = GUISetControl("button", "Update", 210, 190, 80, 40) GUISetControl("button", "Exit", 300, 190, 80, 40) While 1 $N=GuiMsg () IF GuiRead($N)="Exit" Then Exit IF GuiRead($N)="Browse" Then $data = FileOpenDialog("Browse", "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 ) Endif IF $N=18 Then ExitLoop WEND GUIHide() Link to comment Share on other sites More sharing options...
pekster Posted July 9, 2004 Share Posted July 9, 2004 Just take the result of your FileOpenDialog command and feed it to the edit box. I've created a small example with a read-only edit field that displays the selection, and a browse button that will update the edit field with the selection: $ES_READONLY = 0x0800 Opt("GUINotifyMode", 1) GuiCreate("Example", 300, 40) $box = GuiSetControl("input", "", 0, 0, 300, 20, $ES_READONLY) $browse = GuiSetControl("button", "browse", 0, 20, 150, 20) $exit = GuiSetControl("button", "exit", 150, 20, 150, 20) GuiShow() While 1 $n = GuiMsg() Select Case $n = $browse $file = FileOpenDialog("Choose a file", "", "All (*.*)", 1) If @error Then ContinueLoop GuiWrite($box, 0, $file);set the text to the chosen file Case $n = $exit Exit EndSelect WEnd [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
vickerps Posted July 9, 2004 Author Share Posted July 9, 2004 Thanks Works great. I like the SELECT method to structure things. Much better than my IF's (learn somthing every day) Link to comment Share on other sites More sharing options...
pekster Posted July 9, 2004 Share Posted July 9, 2004 Another note: in your code you tested the return of the GuiMsg command against a number. This is a bad idea since the numbers won't always be the same. It's a much better method to test it agains the return of the GuiSetControl call. That way you can be sure you have the correct control number. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. 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