Jump to content
Sign in to follow this  
Heretic

Adding new line to editbox, without deleting current text

Recommended Posts

Heretic

Hello everybody, I was wondering how I would go about adding another line of text to an editbox..

I know that this line will add the text to the end of the line:

 

GUICtrlSetData($editbox, "Button 10 was pressed  ", 1)

 

But how would I add a new line of text, without deleting the text already in the editbox?  

 

  -thanks in advance

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$Form2 = GUICreate("line trial", 552, 178, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form2Restore")
$editbox = GUICtrlCreateEdit("", 8, 8, 409, 169)
GUICtrlSetData(-1, "editbox")
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT)
GUICtrlSetOnEvent(-1, "editboxChange")
$Group1 = GUICtrlCreateGroup("Options", 424, 0, 121, 137)
$Button1 = GUICtrlCreateButton("Button1", 432, 16, 51, 17)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 432, 40, 51, 17)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("Button3", 432, 64, 51, 17)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("Button4", 432, 88, 51, 17)
GUICtrlSetOnEvent(-1, "Button4Click")
$Button5 = GUICtrlCreateButton("Button5", 432, 112, 51, 17)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("Button6", 488, 16, 51, 17)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button7 = GUICtrlCreateButton("Button7", 488, 40, 51, 17)
GUICtrlSetOnEvent(-1, "Button7Click")
$Button8 = GUICtrlCreateButton("Button8", 488, 64, 51, 17)
GUICtrlSetOnEvent(-1, "Button8Click")
$Button9 = GUICtrlCreateButton("Button9", 488, 88, 51, 17)
GUICtrlSetOnEvent(-1, "Button9Click")
$Button10 = GUICtrlCreateButton("Button10", 488, 112, 51, 17)
GUICtrlSetOnEvent(-1, "Button10Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button11 = GUICtrlCreateButton("Exit", 424, 144, 59, 25)
GUICtrlSetOnEvent(-1, "Button11Click")
$Button12 = GUICtrlCreateButton("Clear", 496, 144, 51, 25)
GUICtrlSetOnEvent(-1, "Button12Click")
GUISetState(@SW_SHOW)
Global $File1 = "test.txt"




While 1
    Sleep(100)
WEnd



Func Button10Click()
GUICtrlSetData($editbox, "Button 10 was pressed  ")
FileWriteLine($File1, "Button 10 was pressed")
EndFunc




Func Button11Click()
   If FileExists("test.txt") Then
      FileDelete ( "test.txt" )
      exit
   Else   
      exit
EndIf
EndFunc




Func Button12Click()
GUICtrlSetData($editbox, "")
EndFunc




Func Button1Click()
 GUICtrlSetData($editbox, "Button 1 was pressed  ")
 FileWriteLine($File1, "Button 1 was pressed")
EndFunc




Func Button2Click()
 GUICtrlSetData($editbox, "Button 2 was pressed  ")
 FileWriteLine($File1, "Button 2 was pressed")
EndFunc




Func Button3Click()
 GUICtrlSetData($editbox, "Button 3 was pressed  ")
 FileWriteLine($File1, "Button 3 was pressed")
EndFunc




Func Button4Click()
 GUICtrlSetData($editbox, "Button 4 was pressed  ")
 FileWriteLine($File1, "Button 4 was pressed")
EndFunc




Func Button5Click()
 GUICtrlSetData($editbox, "Button 5 was pressed  ")
 FileWriteLine($File1, "Button 5 was pressed")
EndFunc




Func Button6Click()
 GUICtrlSetData($editbox, "Button 6 was pressed  ")
 FileWriteLine($File1, "Button 6 was pressed")
EndFunc




Func Button7Click()
 GUICtrlSetData($editbox, "Button 7 was pressed  ", 1)
 FileWriteLine($File1, "Button 7 was pressed")
EndFunc




Func Button8Click()
 GUICtrlSetData($editbox, "Button 8 was pressed  ")
 FileWriteLine($File1, "Button 8 was pressed")
EndFunc




Func Button9Click()
 GUICtrlSetData($editbox, "Button 9 was pressed  ")
 FileWriteLine($File1, "Button 9 was pressed")
EndFunc




Func editboxChange()
EndFunc




Func Form2Close()
   If FileExists("test.txt") Then
      FileDelete ( "test.txt" )
      exit
   Else   
      exit
EndIf
EndFunc

Share this post


Link to post
Share on other sites
Heretic

GUICtrlSetData($editbox, "Button 10 was pressed" & @CRLF, 1)

nevermind, figured it out..     :oops:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

$Form2 = GUICreate("line trial", 552, 178, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form2Restore")
$editbox = GUICtrlCreateEdit("", 8, 8, 409, 169)
GUICtrlSetData(-1, "")
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT)
GUICtrlSetOnEvent(-1, "editboxChange")
$Group1 = GUICtrlCreateGroup("Options", 424, 0, 121, 137)
$Button1 = GUICtrlCreateButton("Button1", 432, 16, 51, 17)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 432, 40, 51, 17)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("Button3", 432, 64, 51, 17)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("Button4", 432, 88, 51, 17)
GUICtrlSetOnEvent(-1, "Button4Click")
$Button5 = GUICtrlCreateButton("Button5", 432, 112, 51, 17)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("Button6", 488, 16, 51, 17)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button7 = GUICtrlCreateButton("Button7", 488, 40, 51, 17)
GUICtrlSetOnEvent(-1, "Button7Click")
$Button8 = GUICtrlCreateButton("Button8", 488, 64, 51, 17)
GUICtrlSetOnEvent(-1, "Button8Click")
$Button9 = GUICtrlCreateButton("Button9", 488, 88, 51, 17)
GUICtrlSetOnEvent(-1, "Button9Click")
$Button10 = GUICtrlCreateButton("Button10", 488, 112, 51, 17)
GUICtrlSetOnEvent(-1, "Button10Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button11 = GUICtrlCreateButton("Save", 424, 144, 59, 25)
GUICtrlSetOnEvent(-1, "Button11Click")
$Button12 = GUICtrlCreateButton("Clear", 496, 144, 51, 25)
GUICtrlSetOnEvent(-1, "Button12Click")
GUISetState(@SW_SHOW)
Global $File1 = "test.txt"
Global $Button1setting = "Button 1 was pressed."
Global $Button2setting = "Button 2 was pressed."
Global $Button3setting = "Button 3 was pressed."
Global $Button4setting = "Button 4 was pressed."
Global $Button5setting = "Button 5 was pressed."
Global $Button6setting = "Button 6 was pressed."
Global $Button7setting = "Button 7 was pressed."
Global $Button8setting = "Button 8 was pressed."
Global $Button9setting = "Button 9 was pressed."
Global $Button10setting = "Button 10 was pressed."


While 1
    Sleep(100)
WEnd


Func editboxChange()
Global $editline1 = GUICtrlRead($editbox)   
GUICtrlSetData($editbox, $editline1)   
EndFunc





Func Button1Click()
 GUICtrlSetData($editbox, $Button1setting & @CRLF, 1)
EndFunc





Func Button2Click()
 GUICtrlSetData($editbox, $Button2setting & @CRLF, 1)
EndFunc





Func Button3Click()
 GUICtrlSetData($editbox, $Button3setting & @CRLF, 1)
EndFunc





Func Button4Click()
 GUICtrlSetData($editbox, $Button4setting & @CRLF, 1)
EndFunc





Func Button5Click()
 GUICtrlSetData($editbox, $Button5setting & @CRLF, 1)
EndFunc





Func Button6Click()
 GUICtrlSetData($editbox, $Button6setting & @CRLF, 1)
EndFunc





Func Button7Click()
 GUICtrlSetData($editbox, $Button7setting & @CRLF, 1)
EndFunc





Func Button8Click()
 GUICtrlSetData($editbox, $Button8setting & @CRLF, 1)
EndFunc





Func Button9Click()
 GUICtrlSetData($editbox, $Button9setting & @CRLF, 1)
EndFunc





Func Button10Click()
GUICtrlSetData($editbox, $Button10setting & @CRLF, 1)
EndFunc











Func Button11Click()
 Global $editboxinput = GUICtrlRead($editbox)
 FileWriteLine($File1, $editboxinput)
EndFunc





Func Button12Click()
GUICtrlSetData($editbox, "")
EndFunc













Func Form2Close()
   If FileExists("test.txt") Then
      FileDelete ( "test.txt" )
      exit
   Else   
      exit
EndIf
EndFunc
Edited by Heretic

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  

×