Jump to content

GUICtrlCreateEdit implements words through GUICtrlCreateCombo


Recommended Posts

 

Hi guys,

I would like to implement the words in GuiCtrlCreateEdit through the choices the GuiCtrlCreateCombo. Each item in the GuiCtrlCreateCombo must contain the words that are to be reported later in the GuiCtrlCreateEdit. I have attached an example , I added just a GuiCtrlCreateCombo , then it will insert more.

Thanks for the attention

example.png

Link to comment
Share on other sites

I can see only a picture as a example for what you want but no script what you have already tried.

I am also not sure if understand correct, 2 posibilities:

  1. when choosen a word in combo and confirmed it should be inserted in the edit
  2. same as 1 but inserting a small text which is represented by the word in combo.

1. is banal i am sure you can do alone: GuitrlrRead and GuitrlSetData will be your friends.

For the 2. one a old example script:

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=TextBausteine.exe
#AutoIt3Wrapper_Compression=4
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include<WindowsConstants.au3>
#include <GuiComboBox.au3>

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.6.1
    Author: AutoBert:   http://www.autoit.de/index.php?page=Thread&postID=164445#post164445

    Skriptbeispiel für den Umgang mit INI-Files und ComboBox und Edit
#ce ----------------------------------------------------------------------------




Const $sElect = "Textbaustein auswählen"
Const $sAppIni=@AppDataDir&"\Textbausteine.INI"
Global $sTB

If Not FileExists($sAppIni) Then ;Ini-File vorbelegen
    $sData = "Hilfe=Hier kannst du dir die [url='http://translation.autoit.de/autoitinfo/hilfedateien/AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-09_05_10.zip']Hilfe[/url] herunterladen." & @CRLF
    $sData &= "Tutorial=Hier gibt es ein Tutorial: [url]http://wiki.autoit.de/wiki/index.php/Tutorial[/url]" & @CRLF
    $sData &= "richtigPosten=[url='http://www.autoit.de/index.php?page=Thread&threadID=4424']Autoit-Anfänger Guide / Wie poste ich richtig?[/url]?" & @CRLF
    $sData &= "Buch peethebee=Sehr hilfreich ist auch das [url='http://www.autoit.de/index.php?page=Thread&postID=92818#post92818']Buch[/url] von @peethebee"
    IniWriteSection($sAppIni, "Bausteine", $sData)
EndIf

Global $sTitel = 'Beispiel für wiederkehrende Textbausteine'

Local $hMainGui = GUICreate($sTitel, 800, 520, 140, 150, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
;erzeugt eine GUI die zurückgebebene ID wird in der Variablen $hMainGui gespeichert
;die GUI hat BOXen für Mininmieren, Maximieren und ist in der Größe frei änderbar

Global $hedtBox = GUICtrlCreateEdit("", 10, 10, 600, 480, BitOR($ES_WANTRETURN, $ES_MULTILINE))
;erzeugt ein Edit Steuerelement die zurückgegebe ID wird in der Variablen $hedtBox gespeichert
GUICtrlSetResizing(-1, $GUI_DOCKBORDERs)
;verankert das Inputfield an allen Seiten
;beim Resizen bleibt es dadurch auf seiner Position und den Abstand zu den Seiten es ändert lediglich Breite und Höhe

Global $hcboTB = GUICtrlCreateCombo("", 620, 10, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)
$hbtnAdd = GUICtrlCreateButton("&Hinzufügen Textbaustein", 620, 40, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)
$hbtnDel = GUICtrlCreateButton("&Löschen Textbaustein", 620, 70, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)
$hbtnSave = GUICtrlCreateButton("Änderungen &speichern", 620, 100, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)
$hbtnToClip = GUICtrlCreateButton("&ins ClipBoard", 620, 150, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)
$hbtnFromClip = GUICtrlCreateButton("&aus ClipBoard", 620, 180, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)
$hbtnClear = GUICtrlCreateButton("&Neu (leere EditBox)", 620, 210, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP)

$hbtnExit = GUICtrlCreateButton('Be&enden', 620, 260, 150, 25)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM)

read_INI()
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hbtnExit
            GUIDelete($hMainGui)
            Exit
        Case $hcboTB ;ComboBoxauswahl wurde geändert
            show_Selection()
        Case $hbtnAdd ;Hinzufügen Textbaustein"
            _addTB()
        Case $hbtnDel ;"&Löschen Textbaustein"
            $sDel = GUICtrlRead($hcboTB) ;Kurzbezeichnung holen
            IniDelete($sAppIni, "Bausteine", $sDel) ;aus INI löschen
            GUICtrlSetData($hcboTB, "") ;ComboBox leeren
            read_INI() ;Routine zum INI einlesen aufrufen
            show_Selection() ;Routine zum anzeigen der Selektion aufrufen
        Case $hbtnSave ;"Änderungen &speichern"
            If GUICtrlRead($hcboTB) = $sElect Then
                ;es ist kein Textbaustein selektiert
                GUICtrlSetState($hbtnClear, $GUI_DISABLE)
                GUICtrlSetData($hedtBox, "")
                _addTB() ;
            Else
                $sId_TB = GUICtrlRead($hcboTB) ;Kurzbezeichnung holen
                _writeTB($sId_TB) ;Routine zum Schreiben aufrufen
            EndIf
        Case $hbtnToClip ;"&ins ClipBoard"
            ClipPut(GUICtrlRead($hedtBox))
        Case $hbtnFromClip ;"&aus ClipBoard"
            ;Daten aus Clipboard holen  EditBox wird mit Clipboard überschrieben
            GUICtrlSetData($hedtBox, ClipGet())
        Case $hbtnClear ;"&Neu (leere EditBox)"
            GUICtrlSetData($hcboTB, $sElect,$sElect)
            show_Selection() ;Routine zum anzeigen der Selektion aufrufen
    EndSwitch
WEnd

Func read_INI() ;Ini einlesen
    $list1 = IniReadSection($sAppIni, "Bausteine")
    If IsArray($list1) Then ;nur wenn Array da ansonsten Absturz
        For $i = 1 To $list1[0][0] ;von 1 bis zum letzen Eintrag im Array
            GUICtrlSetData($hcboTB, $list1[$i][0]) ;in ComboBox eintragen
        Next
    EndIf
    _GUICtrlComboBox_InsertString($hcboTB, $sElect, 0) ;$sElect (= "Textbaustein auswählen") an erster Stelle einfügen
    _GUICtrlComboBox_SetCurSel($hcboTB, 0) ;1 Eintrag selektieren
EndFunc   ;==>read_INI

Func _addTB()
    $write1 = GUICtrlRead($hedtBox)
    If $write1 <> "" Then ;nur wenn im Edit etwas eingetragen
        $write2 = InputBox("Baustein verwalten  unter", "Bitte Kurzbegriff eingeben")
        If $write2 <> "" Then ;nur wenn ein Kurzbegrigg eingegeben
            _writeTB($write2) ;Routine zum schreiben aufrufen
            GUICtrlSetData($hcboTB, $write2, $write2) ;in ComboBox eintragen und gleichzeitig selektieren
        EndIf
    EndIf
    show_Selection() ;Routine die die Selektion zeigt aufrufen
EndFunc   ;==>_addTB

Func _writeTB($sId_TB) ;Routine zum Screiben in INI
    ;hier werdeb die Zeichen @CR (Wagebrücklauf) @LF Zeilenumbruche und @CRLF getauscht
    $write1 = GUICtrlRead($hedtBox)
    $write1 = StringReplace($write1, @CRLF, "_%CRLF%_")
    $write1 = StringReplace($write1, @CR, "_%CR%_")
    $write1 = StringReplace($write1, @LF, "_%LF%_")
    If $write1 <> "" Then IniWrite($sAppIni, "Bausteine", $sId_TB, $write1) ;wenn nicht leer in INI schreien
EndFunc   ;==>_writeTB

Func show_Selection() ;Selekzion anzeigen
    If GUICtrlRead($hcboTB) = $sElect Then ;es ist kein Textbaustein asgewählt
        GUICtrlSetState($hbtnClear, $GUI_DISABLE) ;Leeren-Button disablen
        GUICtrlSetData($hedtBox, "") ;also EDIT leeren
    Else
        GUICtrlSetState($hbtnClear, $GUI_ENABLE) ;Leeren-Button enablen
        $sId_TB = GUICtrlRead($hcboTB) ;Kurzbezeichnng holen
        ;ConsoleWrite("ausgewählt: " & $sId_TB & @CRLF)    ;Kontrolausgabe in Console
        $write1 = IniRead($sAppIni, "Bausteine", $sId_TB, "") ;Baustein aus INI lesen
        ;hier werdeb die Zeichen für @CR (Wagebrücklauf) @LF Zeilenumbruche und @CRLF zurück getauscht
        $write1 = StringReplace($write1, "_%CRLF%_", @CRLF) ;
        $write1 = StringReplace($write1, "_%CR%_", @CR)
        $write1 = StringReplace($write1, "_%LF%_", @LF)

        GUICtrlSetData($hedtBox, $write1) ;Baustein in Edit-Box anzeigen
    EndIf
EndFunc   ;==>show_Selection

it's commented in german but i hope the script code is good enough for understanding what i am done.

Edited by AutoBert
Link to comment
Share on other sites

$form_note = GUICreate("Link Note", 790, 300, -1, -1)
GUISetFont(10, 400, 0, "Calibri")
GUISetBkColor(0xFFFFFF)
$button = GUICtrlCreateButton("Prossimo", 700, 200, 80, 50)
GUICtrlCreateLabel("1- Tipo contatto:", 5, 3)
$contact = GUICtrlCreateCombo("", 5, 20, 100, 10, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Backoffice")
$edit = GUICtrlCreateEdit("***** " & $data & "", 5, 145, 690, 150, $CBS_AUTOHSCROLL)
GUISetState(@SW_SHOW, $form_note)

While 1
   $msg2 = GUIGetMsg()
   Switch $msg2
      Case $GUI_EVENT_CLOSE
         Exit
      Case $contact
         If GUICtrlRead($contact) = "Backoffice" Then
            _GUICtrlEdit_AppendText($edit, " white.. *****" & @CRLF & "Serial: ")
            GUICtrlCreateLabel("2- serial:", 115, 3)
            $serial = GUICtrlCreateInput("", 115, 20, 110, 23)
            GUICtrlSetState($tipocontatto, $GUI_DISABLE)
         EndIf
      Case $button
         _GUICtrlEdit_AppendText($edit, $serial)
   EndSwitch
WEnd

 

I can not carry this GuiCtrlCreateInput sentence in GuiCtrlCreateEdit ..
what is missing?

Link to comment
Share on other sites

$form_note = GUICreate("Link Note", 790, 300, -1, -1)
GUISetFont(10, 400, 0, "Calibri")
GUISetBkColor(0xFFFFFF)
$button = GUICtrlCreateButton("Prossimo", 700, 200, 80, 50)
GUICtrlCreateLabel("1- Tipo contatto:", 5, 3)
$contact = GUICtrlCreateCombo("", 5, 20, 100, 10, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Backoffice")
$edit = GUICtrlCreateEdit("***** " & $data & "", 5, 145, 690, 150, $CBS_AUTOHSCROLL)
GUISetState(@SW_SHOW, $form_note)

While 1
   $msg2 = GUIGetMsg()
   Switch $msg2
      Case $GUI_EVENT_CLOSE
         Exit
      Case $contact
         If GUICtrlRead($contact) = "Backoffice" Then
            _GUICtrlEdit_AppendText($edit, " white.. *****" & @CRLF & "Serial: ")
            GUICtrlCreateLabel("2- serial:", 115, 3)
            $serial = GUICtrlCreateInput("", 115, 20, 110, 23)
            GUICtrlSetState($tipocontatto, $GUI_DISABLE)
         EndIf
      Case $button
         _GUICtrlEdit_AppendText($edit, $serial)
   EndSwitch
WEnd

 

I can not carry this GuiCtrlCreateInput sentence in GuiCtrlCreateEdit ..
what is missing?

Link to comment
Share on other sites

#include <GUIEdit.au3>
#include <GUIConstants.au3>

$form_note = GUICreate("Link Note", 790, 300, -1, -1)
GUISetFont(10, 400, 0, "Calibri")
GUISetBkColor(0xFFFFFF)
$button = GUICtrlCreateButton("Prossimo", 700, 200, 80, 50)
GUICtrlCreateLabel("1- Tipo contatto:", 5, 3)
$contact = GUICtrlCreateCombo("", 5, 20, 100, 10, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Backoffice")
$data = 1
$edit = GUICtrlCreateEdit("***** " & $data & "", 5, 145, 690, 150, $CBS_AUTOHSCROLL)
GUISetState(@SW_SHOW, $form_note)

While 1
   $msg2 = GUIGetMsg()
   Switch $msg2
      Case $GUI_EVENT_CLOSE
         Exit
      Case $contact
         If GUICtrlRead($contact) = "Backoffice" Then
            _GUICtrlEdit_AppendText($edit, " white.. *****" & @CRLF & "Serial: ")
            GUICtrlCreateLabel("2- serial:", 115, 3)
            $serial = GUICtrlCreateInput("", 115, 20, 110, 23)
            $tipocontatto = 2
            GUICtrlSetState($tipocontatto, $GUI_DISABLE)
            $edit = GUICtrlCreateEdit("***** " & $data & "", 5, 145, 690, 150, $CBS_AUTOHSCROLL)
         EndIf
       Case $button
;~       _GUICtrlEdit_AppendText($edit, $serial); <=============== Your line here is strange
         _GUICtrlEdit_AppendText($edit, @CRLF & "Serial: " & GUICtrlRead($serial)); <========= test this one
   EndSwitch
WEnd

 

Link to comment
Share on other sites

 

thank you so much.

Last question. I can not declare a variable in a different CASE ?

 

While 1
   $msg2 = GUIGetMsg()
   Switch $msg2
      Case $icona2
         GUISetState(@SW_MINIMIZE, $form_note)
      Case $GUI_EVENT_CLOSE, $chiudi2
         Exit
      Case $GUI_EVENT_PRIMARYDOWN
         _SendMessage($form_note, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
      Case $typecontact
         If GUICtrlRead($typecontact) = "Backoffice" Then
            _GUICtrlEdit_AppendText($edit, " BO *****" & @CRLF & "Number: ")
            GUICtrlSetState($typecontact, $GUI_DISABLE)
         EndIf
         GUICtrlCreateLabel("2- Number:", 115, 3)
         $number = GUICtrlCreateInput("", 115, 20, 100, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
      Case $next ; (create button)
         _GUICtrlEdit_AppendText($edit, GUICtrlRead($number))
         GUICtrlSetState($number, $GUI_DISABLE)
         GUICtrlCreateLabel("3- Serial:", 225, 3)
         $serial = GUICtrlCreateInput("", 225, 20, 130, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
         GUICtrlSetState($next, $GUI_HIDE)
         $next1 = GUICtrlCreateButton("Next", 678, 195, 80, 50)
         GUICtrlSetBkColor(-1, 0x00CC00)
         GUICtrlSetFont(-1, 12, 500, 100, "Calibri")
         GUICtrlSetColor(-1, 0xffffff)
      Case $next1
         _GUICtrlEdit_AppendText($edit, GUICtrlRead($serial))
         GUICtrlSetState($serial, $GUI_DISABLE)
   EndSwitch
WEnd

 

 

I should bring up the CreateInput or ComboList sequentially , while maintaining the NEXT button to fast forward..

Edited by PINTO1927
Link to comment
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
 Share

×
×
  • Create New...