Jump to content

Recommended Posts

Posted

I have created a GUI with two Edit and one button, when the button is pressed, I would like to have my code start reading the data in one Edit and write data into another Edit.

Is this possible?

Could someone show me the syntax for reading and writing data onto Edit?

Thanks

Posted

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

$Form1 = GUICreate("CodeConverter", 625, 443, 261, 124)
$Edit1 = GUICtrlCreateEdit("", 120, 16, 425, 169)
GUICtrlSetData(-1, "Source")
$Edit2 = GUICtrlCreateEdit("", 120, 208, 425, 185)
GUICtrlSetData(-1, "Ouput")

$Button1 = GUICtrlCreateButton("Generate", 16, 16, 89, 25, $WS_GROUP)

GUICtrlSetOnEvent($Button1, "CodeConverting")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
  Sleep(1000)  ; Idle around
WEnd

Func CodeConverting()

;code to read data in Edit1 and write data on Edit2

EndFunc

Func CLOSEClicked()
    Exit
EndFunc

Posted

GuiCtrlRead() on the first edit will give you the contents of the first edit.

GuiCtrlSetData() can be used to push those contents into the second edit.

#include <GUIConstantsEx.au3>

GUICreate("test", 500, 200)
$input1 = GUICtrlCreateInput("This is edit 1", 10, 10, 450, 20)
$input2 = GUICtrlCreateInput("... edit 2 ...", 10, 40, 450, 20)
$button = GUICtrlCreateButton("Copy contents of edit1 into edit2", 10, 80, 450, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg == $GUI_EVENT_CLOSE Then Exit
    If $msg == $button Then
        $contentOfInput1 = GUICtrlRead($input1)
        GUICtrlSetData($input2, $contentOfInput1)
    EndIf
    Sleep(10)
WEnd

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Posted

GuiCtrlRead() on the first edit will give you the contents of the first edit.

GuiCtrlSetData() can be used to push those contents into the second edit.

#include <GUIConstantsEx.au3>

GUICreate("test", 500, 200)
$input1 = GUICtrlCreateInput("This is edit 1", 10, 10, 450, 20)
$input2 = GUICtrlCreateInput("... edit 2 ...", 10, 40, 450, 20)
$button = GUICtrlCreateButton("Copy contents of edit1 into edit2", 10, 80, 450, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg == $GUI_EVENT_CLOSE Then Exit
    If $msg == $button Then
        $contentOfInput1 = GUICtrlRead($input1)
        GUICtrlSetData($input2, $contentOfInput1)
    EndIf
    Sleep(10)
WEnd

Thanks!!!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...