Sign in to follow this  
Followers 0
FMS

When select combobox change input field

4 posts in this topic

#1 ·  Posted (edited)

Hello,

I've writing this code and I'm a little stuck in what i want to do.
When I select the combobox I want to get the ini information inside the multiline input field.

I know that what I'm doing now is wrong but maybe this helps to clearify things in what I want to do.

Does somebody knows how to do this , or can help me?
 

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <Date.au3>

check_file_exist()


$Form1 = GUICreate("Form1", 320, 260, 192, 324);(b,h,,),30
$Tab1 = GUICtrlCreateTab(5, 5, 310, 250) ;(,,b,h)
   $TabSheet3 = GUICtrlCreateTabItem("Edit")
      $Label_tab_select = GUICtrlCreateLabel("select", 40, 50, 80, 25)
      $tab_select = GUICtrlCreateCombo(" tab 1", 40, 70, 80, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
         GUICtrlSetData(-1, " tab 2")
      $Label_BtnSelect = GUICtrlCreateLabel("nr", 125, 50, 80, 25)
      $BtnSelect = GUICtrlCreateCombo(" 1", 125, 70, 60, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
         GUICtrlSetData(-1, " 2 ")
      $Label_BtnName = GUICtrlCreateLabel("name", 190, 50, 80, 25)
      $BtName = GUICtrlCreateInput("", 190, 70, 80, 21)
      $multiline = GuiCtrlCreateEdit("this text needs to be changed at selection of combobox",15, 105, 290, 110)
      ;the next line is to clearify things :)
      ;$multiline = GuiCtrlCreateEdit(IniRead($ini_location_buttons, "btn00" & GUICtrlRead($BtnSelect), "text"),15, 105, 290, 110)
      $Btn301 = GUICtrlCreateButton("Cancel", 40, 220, 75, 25)
      $Btn302 = GUICtrlCreateButton("Save", 152, 220, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Btn301
            Exit
         Case $Btn302
            Exit
    EndSwitch
 WEnd

Func check_file_exist()
   If FileExists(@SCRIPTDIR & "\ini.ini") Then
      Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini"
   Else
      If Not _FileCreate(@SCRIPTDIR & "\buttons.ini") Then
         MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting ini.      error:" & @error)
      Else
         Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini"
         create_new_ini()
      EndIf
   EndIf
EndFunc

Func create_new_ini()
   $file = FileOpen($ini_location_buttons, 1)
      Local $i = 1
      local $j = 0
      Do
         if $i = 10 then $j = ""
         FileWrite($file, "[btn0" & $j & $i & "]"& @CRLF)
         FileWrite($file, "button_name=Button " & $i & @CRLF)
         FileWrite($file, "text=lorum ipsum" & $i & @CRLF)
         $i = $i + 1
      Until $i = 3
   FileClose($file)
EndFunc

 

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites



Here's a little script for demostrating Teamworking ComboBox and Ini-functions: Textbausteine.au3

This 2 func's doing the trick:

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

by StringReplace 'ing the  bad chr's for Inifiles when writting and replacing back when reading.

Share this post


Link to post
Share on other sites

Thanks @AutoBert this looks indeed like what i needed :)
unfortunaly I'm a little bit new on autoit and mine deutsch is not that great.
Do you have a more simplefied version?
I do not know how to use theese functions inside mine script :(


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

For understanding the code must be enough for a progidy, german is not needed.

But for better understanding what i did in this 2 funcs, because IniRead terminates reading by first CR or  LF:

  • i just replaced @CRLF, @CR and @LF before writing (IniWrite)
  • After reading (IniRead) i replaced back to origin text 

and here a old example (just extended )of mine with combobox, IniRead and yet 1 multiline Editcontrol: miniDL2.au3

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

  • Similar Content

    • RC86
      By RC86
      Afternoon, I could very well be doing this wrong so feel free to totally advise otherwise - I'm wanting to use a GUI to first display a key from within an INI file, then secondly change the INI file by using a FileSelectFolder command but then I want to see the GUI change to reflect the change I've just made.
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Input1 = GUICtrlCreateInput(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 121, 21) $Button1 = GUICtrlCreateButton("Change", 200, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) EndIf EndSwitch WEnd So 2 part question really: (1) Should I be using GUICtrlCreateInput to display my INI read from within the GUI? (2) How can I refresh the GUI to update that to read the new information I've just written to the GUI?
      Thanks!

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning
      I'm working on a little project, and I was wondering if there's a way ( sure there is ) to insert data to a ComboBox control everytime the user insert some text in the ComboBox which is not in the ComboBox data. I'll try to explain with an example:
      - Form with some data ( ComboBox is empty );
      - User prompt something in the ComboBox: if what the user prompts is not in the ComboBox values ( at the moment empty ), then insert the value in the ComboBox values, in order to have, next time the user prompts the form, the value that he entered.
      More pratical example:
      - First call of the form, ComboBox empty;
      - I prompt "A" in the ComboBox;
      - Second call, in the ComboBox I should see "A";
      - I prompt "B" in the ComboBox;
      - Third call, I should see "A"
                                                 "B";
      - And so on...
      Everytime the form is called, I re-create it, so I think I can't use _GUICtrlComboBox_AddStrings().
      I tried with
      Global $strCboStrings = "" ; When the user prompt the form, the code below is executed. ; I.E. : User prompt "A", after the if I should have "A"; ; In the second call, If I write "B", I should see "A" ; "B"; ; If I write "A" again, in the combobox values should not be any changes. If Not StringInStr($strCboStrings, GUICtrlRead($cboVoiceCategory)) <> 0 Then $strCboStrings &= $strCboStrings & "|" & GUICtrlRead($cboVoiceCategory) EndIf Any suggestion?
      Thanks
    • kstriyhon
      By kstriyhon
      hello Comunity i am new to autoit and i bump into a pitfall regarding the creation of objects in a dinamyc way but more especific  creating combobox at runtime
      i need many comboboxes and sofar i createdthem manually 
      like this 
      $idCombo_1 = GUICtrlCreateCombo("", 500, 40, 130, 21)     $idCombo_2 = GUICtrlCreateCombo("", 500, 70, 130, 21)     $idCombo_3 = GUICtrlCreateCombo("", 500, 100, 130, 21)     $idCombo_4 = GUICtrlCreateCombo("", 500, 130, 130, 21)     $idCombo_5 = GUICtrlCreateCombo("", 500, 160, 130, 21)     $idCombo_6 = GUICtrlCreateCombo("", 500, 190, 130, 21)     $idCombo_7 = GUICtrlCreateCombo("", 500, 220, 130, 21)     $idCombo_8 = GUICtrlCreateCombo("", 500, 250, 130, 21)     $idCombo_9 = GUICtrlCreateCombo("", 500, 280, 130, 21)     GUICtrlSetData($idCombo_1, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_2, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_3, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_4, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_5, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_6, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_7, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_8, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_9, "Item1|Item2|Item3|Item4|Item5") now i need this example but create them at runtime as there are more than 9 combos what i need thanks in advance kind regards
    • LWC
      By LWC
      I've made a program that relies on IniReadSectionNames. It reads (~3K) Autorun.inf files in the working folder and creates a GUI based on their contents.
      I made sure to revert to a default GUI upon @error.
      But someone (with Windows XP SP3 32-bit) reported to me he always gets the default menu.
      I sent him a FileRead command instead and it works! So seemingly there's no access problem to AutoRun.inf.
      In the following demo code, I always hit success, but he always ends up with semi-success:
      Local $hIniLocation = "Autorun.inf" Local $aSections = IniReadSectionNames($hIniLocation) If @error Then $aSections = FileRead($hIniLocation) if @error then msgbox(48, "Double error", "Alternative access failed too due to:" & @crlf & @error & @crlf & @extended) else msgbox(0, "Semi-success", "IniReadSectionNames failed, but alternativaly this file contains:" & @crlf & @crlf & $aSections) endif else msgbox(0, "Success", "IniReadSectionNames worked!") endif Why is that? Is there something further to check with him?
      Autorun.inf
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening guys
      I am working on a little project, in which I have to retrieve 8000+ rows of data from a table, from a SQLite database, to populate a combobox 
      This is what I tried 'til now, but it still takes about 12 seconds to populate the combobox.
      _SQLite_Exec($objDatabase, "BEGIN TRANSACTION;") If _SQLite_GetTable($objDatabase, "SELECT DISTINCT Comune FROM LISTA_COMUNI;", $arrRisultatoQuery, $intRighe, $intColonne) = $SQLITE_OK Then For $i = 2 To UBound($arrRisultatoQuery) - 1 If $i < UBound($arrRisultatoQuery) - 1 Then GUICtrlSetData($cbo_ComuneNascita, $arrRisultatoQuery[$i] & "|") Else GUICtrlSetData($cbo_ComuneNascita, $arrRisultatoQuery[$i]) EndIf Next _SQLite_Exec($objDatabase, "COMMIT;") Are there any other solution to retrieve 8000+ records from a SQLite database?
      Thank you very much