johnmcloud Posted January 2, 2012 Posted January 2, 2012 (edited) Hi guys, i have created this simply gui: $GUI2 = GUICreate("Form1", 309, 442, 194, 55) $EditBase = GUICtrlCreateEdit("", 32, 24, 249, 161) GUICtrlSetData(-1, "") $EditResult= GUICtrlCreateEdit("", 30, 204, 249, 161) GUICtrlSetData(-1, "") $ButtonBase = GUICtrlCreateButton("First", 32, 384, 73, 33) $Button = GUICtrlCreateButton("Second", 204, 385, 73, 33) $Input = GUICtrlCreateInput("", 112, 384, 81, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonBase Func() EndSwitch WEnd $File = FileOpen(@WorkingDir & "\config.ini", 128 + 1) $Read = GUICtrlRead($Editbase) If $read <> "" Then FileWrite($File, $Read) EndIf I have this problem. I want to save a txt from Editbase (work) and the $EditResult read another binary file, i never make this "inverse" process. And, if is possible, make inccassible $EditResult from write, i want only too see/copy the result. Thanks guys for support and happy new year Edited January 2, 2012 by johnmcloud
czardas Posted January 2, 2012 Posted January 2, 2012 (edited) You can use _GUICtrlEdit_GetText() or GUICtrlRead() since both functions will get the text from your edit control. You might also want to look at the functions FileOpen() , FileWrite() and FileCreate() . Happy New Year to you. Edited January 2, 2012 by czardas operator64 ArrayWorkshop
johnmcloud Posted January 2, 2012 Author Posted January 2, 2012 (edited) You can use _GUICtrlEdit_GetText() or GUICtrlRead() since both functions will get the text from your edit control. You might also want to look at the functions FileOpen() , FileWrite() and FileCreate() .Happy New Year to you. I'll change the title, now is more clear.i don't know if i understand, but i don't want to create a file from what i write into Edit Box ( i have just do it ) but i want to set into Edit Box the content of a binary file ( the EditBox need to read the content of a file ).If you can make an example, i'll be gratefulThanks Edited January 2, 2012 by johnmcloud
czardas Posted January 2, 2012 Posted January 2, 2012 (edited) I didn't check all your code, but here is an example function. #include <GUIConstants.au3> #Include <GuiEdit.au3> $GUI2 = GUICreate("Form1", 309, 442, 194, 55) $EditBase = GUICtrlCreateEdit("", 32, 24, 249, 161) GUICtrlSetData(-1, "") $EditResult= GUICtrlCreateEdit("", 30, 204, 249, 161) GUICtrlSetData(-1, "") $ButtonBase = GUICtrlCreateButton("First", 32, 384, 73, 33) $Button = GUICtrlCreateButton("Second", 204, 385, 73, 33) $Input = GUICtrlCreateInput("", 112, 384, 81, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonBase _MyFunction($EditBase) EndSwitch WEnd ;$File = FileOpen(@WorkingDir & "config.ini", 128 + 1) ;$Read = GUICtrlRead($Editbase) ;If $read <> "" Then ;FileWrite($File, $Read) ;EndIf Func _MyFunction($EditBase) Local $sEditData = _GUICtrlEdit_GetText($EditBase) Local $hFile = FileOpen ( "My_Result.txt" , 1 ) ; Change this flag if you want to overwrite the file. Filewrite($hFile, $sEditData) FileClose($hFile) EndFunc Hmm, I misunderstood your question. Use FileRead. Edited January 2, 2012 by czardas operator64 ArrayWorkshop
johnmcloud Posted January 2, 2012 Author Posted January 2, 2012 (edited) Hmm, I misunderstood your question.Yeah, don't worry. I want to read the "My Result.txt" ( in my case is a binary file ) on the second Editbox and, if possible, i want only to copy/read the result on the EditBox and make inacessible to write Edited January 2, 2012 by johnmcloud
czardas Posted January 2, 2012 Posted January 2, 2012 (edited) It's a bit rough and ready, since I have a dinner appointment. expandcollapse popup#include <GUIConstants.au3> #Include <GuiEdit.au3> $GUI2 = GUICreate("Form1", 309, 442, 194, 55) $EditBase = GUICtrlCreateEdit("", 32, 24, 249, 161) GUICtrlSetData(-1, "") $EditResult= GUICtrlCreateEdit("", 30, 204, 249, 161) GUICtrlSetData(-1, "") $ButtonBase = GUICtrlCreateButton("First", 32, 384, 73, 33) $Button = GUICtrlCreateButton("Second", 204, 385, 73, 33) $Input = GUICtrlCreateInput("", 112, 384, 81, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonBase _MyFunction($EditBase) Case $Button _GetFileText("My_Result.txt", $EditResult) EndSwitch WEnd ;$File = FileOpen(@WorkingDir & "config.ini", 128 + 1) ;$Read = GUICtrlRead($Editbase) ;If $read <> "" Then ;FileWrite($File, $Read) ;EndIf Func _GetFileText($hFile, $EditControl) $hFileHandle = FileOpen ($hFile) If @error Then Return SetError(1) ; Error checks needed adding Local $sEditData = FileRead($hFileHandle) _GUICtrlEdit_SetText($EditControl, $sEditData) FileClose($hFileHandle) EndFunc Func _MyFunction($EditBase) Local $sEditData = _GUICtrlEdit_GetText($EditBase) Local $hFile = FileOpen ( "My_Result.txt" , 1 ) ; Change this flag if you want to overwrite the file. If @error Then Return SetError(1) Filewrite($hFile, $sEditData) FileClose($hFile) EndFunc Added some error checks. Good luck with it. Edited January 2, 2012 by czardas operator64 ArrayWorkshop
johnmcloud Posted January 2, 2012 Author Posted January 2, 2012 (edited) Thanks, i'll recode for my GUI Edited January 2, 2012 by johnmcloud
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