Jump to content

When select combobox change input field


FMS
 Share

Recommended Posts

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

Link to comment
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.

Link to comment
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

Link to comment
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

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...