Sign in to follow this  
Followers 0
blumi

Read Textbox, edit Text and show it in 2nd Textbox

8 posts in this topic

I have a GUI with two Textboxes.

In the first I want to insert a text, by clicking on a button I want to read the textbox1, edit the string and then write it into the second textbox of the GUI.

Read textbox1 -> not problem

Edit the string from textbox1 -> no problem

Insert the new text into the second textbox -> problem

Hot to realize this?

Thanks

Share this post


Link to post
Share on other sites



Have you tried 'GuiCtrlSetData'?

It would be easier to help you when you post a small script, that we can see what you are making wrong.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Have you tried 'GuiCtrlSetData'?

It would be easier to help you when you post a small script, that we can see what you are making wrong.

#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

#include <Array.au3>
#include <GUITab.au3>



; Config
$ScriptName         = "TestScript"
$breite             = 400
$hoehe              = 350
$icon               = "logo.ico"
$ButtonBreite1          = 150
$ButtonHoehe1           = 30

$author             = "© Frank"
$version                = "Version 1.0"


; GUI - Breite und Höhe des Fensters
GuiCreate($ScriptName, $breite, $hoehe)

; Textbox 1
GUICtrlCreateLabel ("Textbox1", 10, 25)
$input1 = GUICtrlCreateInput ("Hier der Text zum editieren", 40, 40, 250, 100)
GUICtrlSetTip (-1, "TEST")

; Textbox 2
GUICtrlCreateLabel ("Textbox2", 10, 145)
$input2 = GUICtrlCreateInput ("", 40, 160, 250, 100)
GUICtrlSetTip (-1, "TEST")




$ButtonLos = GuiCtrlCreateButton("&Los", ($breite/3)-($ButtonBreite1/2), $hoehe-60, 100, 30)
GUICtrlSetTip(-1, "Text ändern")

$ButtonExit = GuiCtrlCreateButton("&Ende", (($breite/3)+($breite/3)-($ButtonBreite1/2)), $hoehe-60, 100, 30)
GUICtrlSetTip(-1, "Programm beenden")

; Copyright
GUISetFont (8, 400, 0, 0)
GUICtrlCreateLabel ($author, 10, $hoehe - 20)
GUICtrlCreateLabel ($version, $breite-60, $hoehe - 20)

; Show the GUI
GuiSetState()

While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $ButtonLos
            BearbeiteText()

      Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit
        GUIDelete()
        Exit
    EndSelect
WEnd




; Funktion zum Text bearbeiten und ausgeben
Func BearbeiteText()
    $test = GUICtrlRead($input1)
    ;MsgBox(64, $ScriptName, $test)

    $test = $test & "12345"
    $test = $test & @LF & "67890"

    $input2 = GUICtrlCreateInput ($test, 40, 160, 250, 100)
    ;MsgBox(64, $ScriptName, $test)


EndFunc

Share this post


Link to post
Share on other sites

Use Edit instead of Input and do not create a new input instead of updating the old one.

#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

#include <Array.au3>
#include <GUITab.au3>

 

; Config
$ScriptName = "TestScript"
$breite = 400
$hoehe = 350
$icon = "logo.ico"
$ButtonBreite1 = 150
$ButtonHoehe1 = 30

$author = "© Frank"
$version = "Version 1.0"


; GUI - Breite und Höhe des Fensters
GUICreate($ScriptName, $breite, $hoehe)

; Textbox 1
GUICtrlCreateLabel("Textbox1", 10, 25)
$input1 = GUICtrlCreateEdit("Hier der Text zum editieren", 40, 40, 250, 100, BitOR(0x40, 0x80))
GUICtrlSetTip(-1, "TEST")

; Textbox 2
GUICtrlCreateLabel("Textbox2", 10, 145)
$input2 = GUICtrlCreateEdit("", 40, 160, 250, 100, BitOR(0x40, 0x80))
GUICtrlSetTip(-1, "TEST")

 


$ButtonLos = GUICtrlCreateButton("&Los", ($breite / 3) - ($ButtonBreite1 / 2), $hoehe - 60, 100, 30)
GUICtrlSetTip(-1, "Text ändern")

$ButtonExit = GUICtrlCreateButton("&Ende", (($breite / 3) + ($breite / 3) - ($ButtonBreite1 / 2)), $hoehe - 60, 100, 30)
GUICtrlSetTip(-1, "Programm beenden")

; Copyright
GUISetFont(8, 400, 0, 0)
GUICtrlCreateLabel($author, 10, $hoehe - 20)
GUICtrlCreateLabel($version, $breite - 60, $hoehe - 20)

; Show the GUI
GUISetState()

While 1
 $msg = GUIGetMsg()

 Select
  Case $msg = $ButtonLos
   BearbeiteText()

  Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit
   GUIDelete()
   Exit
 EndSelect
WEnd


; Funktion zum Text bearbeiten und ausgeben
Func BearbeiteText()
 $test = GUICtrlRead($input1)
 ;MsgBox(64, $ScriptName, $test)

 $test = $test & "12345"
 $test = $test & @CRLF & "67890"

 GUICtrlSetData($input2, $test)
 ;MsgBox(64, $ScriptName, $test)


EndFunc   ;==>BearbeiteText

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Okay, tried it, works fine, thanks a lot.

Another question.

Is there a way to use/show the @CRLF in the Textbox?

It seems to be ignored.

Share this post


Link to post
Share on other sites

Add the style $ES_WANTRETURN (0x1000) to the edit control.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Add the style $ES_WANTRETURN (0x1000) to the edit control.

You mean something like this:

; Textbox 2
GUICtrlCreateLabel ("Textbox2", 10, 145)
$input2 = GUICtrlCreateEdit ("", 40, 160, 250, 100, 0x1000)
;$input2 = GUICtrlCreateInput ("", 40, 160, 250, 100)
GUICtrlSetTip (-1, "TEST")

Share this post


Link to post
Share on other sites

I made it. ;-)

; Textbox 2
GUICtrlCreateLabel ("Textbox2", 10, 145)
$input2 = GUICtrlCreateEdit ("", 40, 160, 250, 100, $ES_WANTRETURN)
GUICtrlSetTip (-1, "TEST")

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  
Followers 0