Crashrider Posted February 16 Share Posted February 16 expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> ; Pfad zur INI-Datei Global $sIniFile = "C:\Users\Crashrider\Desktop\BFB_Tool\Source\Standorte.ini" ; Erstellt GUI Global $hGUI = GUICreate("INI Dropdown", 400, 200) ; Erstellt ComboBox Global $cComboBox = GUICtrlCreateCombo("", 10, 10, 150, 25, $CBS_DROPDOWNLIST) ; Liest Abschnitte aus INI-Datei Global $aSections = IniReadSectionNames($sIniFile) ; Überprüft, ob Abschnitte vorhanden sind If Not @error Then ; Fügt Abschnitte zur ComboBox hinzu GUICtrlSetData($cComboBox, "|" & _ArrayToString($aSections, "|")) GUICtrlSetState($cComboBox, $GUI_FOCUS) ; Setzt den Fokus auf die ComboBox EndIf ; Erstellt Textfelder Global $cTextField1 = GUICtrlCreateInput("", 180, 10, 200, 20) Global $cTextField2 = GUICtrlCreateInput("", 180, 40, 200, 20) Global $cTextField3 = GUICtrlCreateInput("", 180, 70, 200, 20) Global $cTextField4 = GUICtrlCreateInput("", 180, 100, 200, 20) Global $cTextField5 = GUICtrlCreateInput("", 180, 130, 200, 20) ; Registriert Event für die ComboBox GUIRegisterMsg($WM_COMMAND, "OnComboBoxChange") GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func OnComboBoxChange($hWnd, $iMsg, $wParam, $lParam) If $wParam = $cComboBox And BitAND(GUIGetMsgCode(), $CBN_SELCHANGE) Then ; Liest ausgewählten Abschnitt aus ComboBox Local $sSelectedSection = GUICtrlRead($cComboBox) ; Überprüft, ob ein Abschnitt ausgewählt wurde If $sSelectedSection <> "" Then ; Liest Schlüssel-Wert-Paare aus ausgewähltem Abschnitt Local $aKeyValuePairs = IniReadSection($sIniFile, $sSelectedSection) ; Überprüft, ob Schlüssel-Wert-Paare vorhanden sind If Not @error Then ; Setzt die Werte in die Textfelder GUICtrlSetData($cTextField1, GetValueFromIniArray($aKeyValuePairs, "Var1")) GUICtrlSetData($cTextField2, GetValueFromIniArray($aKeyValuePairs, "Var2")) GUICtrlSetData($cTextField3, GetValueFromIniArray($aKeyValuePairs, "Var3")) GUICtrlSetData($cTextField4, GetValueFromIniArray($aKeyValuePairs, "Var4")) GUICtrlSetData($cTextField5, GetValueFromIniArray($aKeyValuePairs, "Var5")) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Func GetValueFromIniArray($aArray, $sKey) For $i = 1 To $aArray[0][0] If $aArray[$i][0] = $sKey Then Return $aArray[$i][1] EndIf Next Return "" EndFunc thats the Code i gues that does not perform... GUIRegisterMsg($WM_COMMAND, "OnComboBoxChange") I would love to change to setonevent mode but cant find an example für setonevent for dropdown with an ini File. Ini looks like this [Ludwigshafen] Var1=Wert1 Var2=Wert2 Var3=Wert3 Var4=Wert4 Var5=wert5 [Berlin] Var1=Wert1 Var2=Wert2 Var3=Wert3 Var4=Wert4 Var5=wert5 Realy could use some help. Cheers Link to comment Share on other sites More sharing options...
Solution Nine Posted February 16 Solution Share Posted February 16 (edited) Use this instead in WM_COMMAND as per MSDN: If _WinAPI_LoWord($wParam) = $cComboBox And _WinAPI_HiWord($wParam) = $CBN_SELCHANGE Then and also use this instead to get rid of count : GUICtrlSetData($cComboBox, "|" & _ArrayToString($aSections, "|", 1)) Edited February 16 by Nine Crashrider 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Crashrider Posted February 16 Author Share Posted February 16 works like charm thx a lot. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now