"Arzt" Programm

  • Hallo,
    da meine kleine Schwester gerne Arzt mit ihren Plüschtieren spielt habe ich mir gedacht ich mach ihr ein Programm, indem sie ihre "Patienten" verwalten kann. Doch jetzt komme ich nicht so weiter. Das mit dem Anzeigen der Patienten klappt zwar, aber ich will auch eine Funktion zum löschen der Patienten machen, doch da weiß ich nicht so weiter. Eine Sortierung der Patienten wäre natürlich auch gut. Wie würde das alles einfacher gehen? Hier mal das Script.

    Spoiler anzeigen
    [autoit]

    #include
    #include #include #include #include #include
    $PatientenAnzahl = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Allgemein","Patienten","0")
    $AktuelleAnzahl = 0
    Dim $ID

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 1017, 736, 267, 139)
    $PageControl1 = GUICtrlCreateTab(8, 56, 1007, 707)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße",24, 152, 969, 552)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet2 = GUICtrlCreateTabItem("Neuer Patient")
    $Label1 = GUICtrlCreateLabel("Vorname:", 28, 105, 73, 24)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 28, 137, 85, 24)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 110, 105, 161, 22)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 110, 137, 161, 22)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 28, 169, 111, 24)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 110, 169, 161, 22)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 28, 201, 106, 24)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 110, 201, 161, 22)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 28, 233, 57, 24)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 110, 233, 161, 22)
    GUICtrlSetFont(-1,8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 110, 272, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    $Anzahl = 0
    While 1
    $anzahl = $anzahl + 1
    $Vorname = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Vorname","Nix")
    $Nachname = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Nachname","Nix")
    $Geburtsdatum = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Geburtsdatum","Nix")
    $PLZWohnort = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"PLZ / Wohnort","Nix")
    $Strasse = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Straße","Nix")
    If $Vorname = "Nix" then ExitLoop
    If $Nachname = "Nix" then ExitLoop
    If $Geburtsdatum = "Nix" then ExitLoop
    If $PLZWohnort = "Nix" then ExitLoop
    If $Strasse = "Nix" then ExitLoop
    Assign("Patient" & $anzahl,GUICtrlCreateListViewItem($Vorname & "|" & $Nachname & "|" & $geburtsdatum & "|" & $plzwohnort & "|" & $strasse,$listview1) )
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $PageControl1
    If GUICtrlread ($Pagecontrol1) = 0 then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlread ($Pagecontrol1) = 1 then
    $PatientenAnzahl = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Allgemein","Patienten","0")

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlread ($Pagecontrol1) = 2 then

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    $PatientenAnzahl = $PatientenAnzahl + 1
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite(@ScriptDir & "\Patienten\Patienten.ini","Allgemein","Patienten",$PatientenAnzahl)
    IniWrite(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $PatientenAnzahl,"Vorname",$Vorname)
    IniWrite(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $PatientenAnzahl,"Nachname",$Nachname)
    IniWrite(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $PatientenAnzahl,"Geburtsdatum",$Geburtsdatum)
    IniWrite(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $PatientenAnzahl,"PLZ / Wohnort",$PLZWohnort)
    IniWrite(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $PatientenAnzahl,"Straße",$Strasse)
    $PatientenAnzahl = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Allgemein","Patienten","0")
    GUICtrlSetData($Input1,"")
    GUICtrlSetData($Input2,"")
    GUICtrlSetData($Input3,"DD.MM.YYYY")
    GUICtrlSetData($Input4,"")
    GUICtrlSetData($Input5,"")

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlListView_DeleteAllItems($listview1)
    $Anzahl = 0
    While 1
    $anzahl = $anzahl + 1
    $Vorname = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Vorname","Nix")
    $Nachname = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Nachname","Nix")
    $Geburtsdatum = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Geburtsdatum","Nix")
    $PLZWohnort = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"PLZ / Wohnort","Nix")
    $Strasse = IniRead(@ScriptDir & "\Patienten\Patienten.ini","Patient " & $anzahl,"Straße","Nix")
    If $Vorname = "Nix" then ExitLoop
    If $Nachname = "Nix" then ExitLoop
    If $Geburtsdatum = "Nix" then ExitLoop
    If $PLZWohnort = "Nix" then ExitLoop
    If $Strasse = "Nix" then ExitLoop
    Assign("Patient" & $anzahl,GUICtrlCreateListViewItem($Vorname & "|" & $Nachname & "|" & $geburtsdatum & "|" & $plzwohnort & "|" & $strasse,$listview1) )
    WEnd
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]


    Schonmal im Voraus, Danke!

    Einmal editiert, zuletzt von MOZ (29. November 2008 um 11:59)

    • Offizieller Beitrag

    Einen markierten Eintrag löschst du mit:

    [autoit]

    _GUICtrlListView_DeleteItemsSelected($Listview1)

    [/autoit]


    Dann ist er nicht mehr in der Liste - aber noch in der INI, dort mußt du also auch noch den Eintrag löschen.
    Die INI ist sowieso nicht besonders geeignet als Datenbank. Aber wenn du sie benutzen möchtest, ist es besser nur eine Sektion "Patienten" zu erstellen und jedem Patienten einen eindeutigen Schlüssel zuzuordnen. Sonst läßt er sich nämlich nicht löschen, da alle Patientendaten mehrfach auftreten können.
    Denkbar wäre:

    Code
    [Patienten]
    10000=Meier|Hans|12.12.1990|Mustergasse 77|12345 Teststadt
    10001=Müller|Ilse|09.08.1965|Blumenweg 3a|67890 Schönhausen
    • Offizieller Beitrag

    Was ist den am besten für eine Datenbank?

    Sehr gut geeignet ist SQLite.

    Ich hab deinen Code mal umgestellt (und dabei deutlich gekürzt) auf die von mir empfohlene Verwendung der INI. Wenn dort nur ein paar Plüschtiere verwaltet werden ;) , sollte das ausreichen.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    Local $INI = @ScriptDir & "\Patienten.ini"

    [/autoit] [autoit][/autoit] [autoit]

    ; nur zum Testen:
    If Not FileExists($INI) Then
    IniWrite($INI, "Patienten", 10000, "Peter|Lustig|11.11.1956|12345 Grüner-Wald|Bauwagen 1")
    IniWrite($INI, "Patienten", 10001, "Marion|Rosenbaum|08.12.1987|33445 Irgendwo|Am Feld 35")
    IniWrite($INI, "Patienten", 10002, "Max|Mustermann|12.12.1978|44556 Musterdorf|Mustergasse 17")
    IniWrite($INI, "Numbers", "last", 10002)
    EndIf
    ; Ende Test-INI

    [/autoit] [autoit][/autoit] [autoit]

    Global $aPatienten = IniReadSection($INI, "Patienten")
    Local $lastNum = IniRead($INI, "Numbers", "last", 9999)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 1017, 736, 267, 139)
    $PageControl1 = GUICtrlCreateTab(8, 56, 1007, 707)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Nr|Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße", 24, 152, 969, 552)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    ; ### hier Kontextmenü für ListView einfügen:
    $mnu = GUICtrlCreateContextMenu($Listview1)
    $mnu_del = GUICtrlCreateMenuItem('Patient Löschen', $mnu)
    ; ### Ende Kontextmenü
    $TabSheet2 = GUICtrlCreateTabItem("Neuer Patient")
    $Label1 = GUICtrlCreateLabel("Vorname:", 28, 105, 73, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 28, 137, 85, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 110, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 110, 137, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 28, 169, 111, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 110, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 28, 201, 106, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 110, 201, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 28, 233, 57, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 110, 233, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 110, 272, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    #EndRegion ### START Koda GUI section ### Form=

    [/autoit] [autoit][/autoit] [autoit]

    _FillListView()

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $PageControl1
    If GUICtrlRead($PageControl1) = 0 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 1 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 2 Then

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    $lastNum += 1
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite($INI, "Numbers", "last", $lastNum)
    IniWrite($INI, "Patienten", $lastNum, $Vorname & '|' & $Nachname & '|' & $Geburtsdatum & '|' & $PLZWohnort & '|' & $Strasse)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "DD.MM.YYYY")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    _FillListView()
    Case $mnu_del
    ; Eintrag aus INI löschen:
    $index = _GUICtrlListView_GetSelectedIndices($Listview1)
    $del_Key = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $index, 0)
    IniDelete($INI, "Patienten", $del_key)
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    ; entfernt Eintrag aus Liste:
    _GUICtrlListView_DeleteItemsSelected($Listview1)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _FillListView()
    _GUICtrlListView_DeleteAllItems($Listview1)
    If $lastNum = 9999 Then Return
    For $i = 1 To UBound($aPatienten) -1
    GUICtrlCreateListViewItem($aPatienten[$i][0] & '|' & $aPatienten[$i][1], $Listview1)
    Next
    EndFunc

    [/autoit]

    Edit: Achja - falls du es nicht gleich siehst: Löschen per Kontextmenü im ListView. ;)

  • Cool danke ;)
    Wie könnte man jetzt noch machen, dass ein neues Fenster kommt wenn man doppelt auf einen Patienten drückt?

    • Offizieller Beitrag

    Ich hab dir das mal eingebaut. Kannst du nach deinen Wünschen ausbauen.
    Ich habe alle Ereignisse, die du mit WM_NOTIFY auswerten kannst, mal in der Funktion belassen. Kannst du natürlich entfernen, was du nicht brauchst.

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    Local $INI = @ScriptDir & "\Patienten.ini"

    [/autoit] [autoit][/autoit] [autoit]

    ; nur zum Testen:
    If Not FileExists($INI) Then
    IniWrite($INI, "Patienten", 10000, "Peter|Lustig|11.11.1956|12345 Grüner-Wald|Bauwagen 1")
    IniWrite($INI, "Patienten", 10001, "Marion|Rosenbaum|08.12.1987|33445 Irgendwo|Am Feld 35")
    IniWrite($INI, "Patienten", 10002, "Max|Mustermann|12.12.1978|44556 Musterdorf|Mustergasse 17")
    IniWrite($INI, "Numbers", "last", 10002)
    EndIf
    ; Ende Test-INI

    [/autoit] [autoit][/autoit] [autoit]

    Global $aPatienten = IniReadSection($INI, "Patienten")
    Local $lastNum = IniRead($INI, "Numbers", "last", 9999)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 1017, 736, 267, 139)
    $PageControl1 = GUICtrlCreateTab(8, 56, 1007, 707)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Nr|Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße", 24, 152, 969, 552)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    ; ### hier Kontextmenü für ListView einfügen:
    $mnu = GUICtrlCreateContextMenu($Listview1)
    $mnu_del = GUICtrlCreateMenuItem('Patient Löschen', $mnu)
    ; ### Ende Kontextmenü
    $TabSheet2 = GUICtrlCreateTabItem("Neuer Patient")
    $Label1 = GUICtrlCreateLabel("Vorname:", 28, 105, 73, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 28, 137, 85, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 110, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 110, 137, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 28, 169, 111, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 110, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 28, 201, 106, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 110, 201, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 28, 233, 57, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 110, 233, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 110, 272, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    #EndRegion ### START Koda GUI section ### Form=

    [/autoit] [autoit][/autoit] [autoit]

    $Form2 = GUICreate('Form2')
    $lb_Patient = GUICtrlCreateLabel('', 20, 20, 250, 17)

    [/autoit] [autoit][/autoit] [autoit]

    _FillListView()
    GUISetState(@SW_SHOW, $Form1)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; Window-Handle
    Case $Form1
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    Exit
    Case $PageControl1
    If GUICtrlRead($PageControl1) = 0 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 1 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 2 Then

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    $lastNum += 1
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite($INI, "Numbers", "last", $lastNum)
    IniWrite($INI, "Patienten", $lastNum, $Vorname & '|' & $Nachname & '|' & $Geburtsdatum & '|' & $PLZWohnort & '|' & $Strasse)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "DD.MM.YYYY")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    _FillListView()
    Case $mnu_del
    ; Eintrag aus INI löschen:
    $index = _GUICtrlListView_GetSelectedIndices($Listview1)
    $del_Key = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $index, 0)
    IniDelete($INI, "Patienten", $del_key)
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    ; entfernt Eintrag aus Liste:
    _GUICtrlListView_DeleteItemsSelected($Listview1)
    EndSwitch
    Case $Form2
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    ;~ Case ....

    EndSwitch
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _FillListView()
    _GUICtrlListView_DeleteAllItems($Listview1)
    If $lastNum = 9999 Then Return
    For $i = 1 To UBound($aPatienten) -1
    GUICtrlCreateListViewItem($aPatienten[$i][0] & '|' & $aPatienten[$i][1], $Listview1)
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _LeftDblClick($Info) ; Inhalt der angeklickten Spalte wird in GUI gezeigt
    Local $indx_Item = $Info[3], $indx_Sub = $Info[4]
    GUICtrlSetData($lb_Patient, _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $indx_Item, $indx_Sub))
    GUISetState(@SW_SHOW, $Form2)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $ListView1
    If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hWndListView
    Switch $iCode
    Case $LVN_COLUMNCLICK ; A column was clicked
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ColumnClick($aInfo)
    Case $LVN_DELETEITEM ; An item is about to be deleted
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ItemDeleted($aInfo)
    Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    Return 0 ; allow the list view to perform its normal track select processing.
    ;Return 1 ; the item will not be selected.
    ;~ _HottTrackItem($aInfo)
    Case $LVN_KEYDOWN ; A key has been pressed
    Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
    Local $aInfo[5] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "VKey"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _KeyDown($aInfo)
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _LeftClick($aInfo)
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    _LeftDblClick($aInfo)
    Case $NM_KILLFOCUS ; The control has lost the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _LostFocus($aInfo)
    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ; Return 1 ; not to allow the default processing
    Return 0 ; allow the default processing
    ;~ _RightClick($aInfo)
    Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _RightDblClick($aInfo)
    Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _InputFocusReturn($aInfo)
    Case $NM_SETFOCUS ; The control has received the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _SetFocus($aInfo)
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • okay so ganz verseht ich jetzt nicht mehr was da dann abläuft. was muss ich löschen, damit immer das gleiche im fenster kommt, egal wo man hindrückt(also egal ob auf vorname oder nachname)
    und das mit rechtsklick --> löschen geht bei mir nicht mehr. da kommt nix wenn ich rechtsklick mach

  • Du musst Zeile 244 ( Return 0 ; allow the default processing) löschen oder mit
    Return $GUI_RUNDEFMSG
    ersetzen. (0 erlaubt AutoIt nicht, ein Kontextmenu aufzurufen.)

    • Offizieller Beitrag

    Wenn du alle Einträge der jeweiligen Zeile ausgeben möchtest, verwende statt einem Label z.B. ein Edit in der Anzeige-GUI.
    Ich habe das mal angepaßt (auch die Änderung mit Return $GUI_RUNDEFMSG)

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    Local $INI = @ScriptDir & "\Patienten.ini"

    [/autoit] [autoit][/autoit] [autoit]

    ; nur zum Testen:
    If Not FileExists($INI) Then
    IniWrite($INI, "Patienten", 10000, "Peter|Lustig|11.11.1956|12345 Grüner-Wald|Bauwagen 1")
    IniWrite($INI, "Patienten", 10001, "Marion|Rosenbaum|08.12.1987|33445 Irgendwo|Am Feld 35")
    IniWrite($INI, "Patienten", 10002, "Max|Mustermann|12.12.1978|44556 Musterdorf|Mustergasse 17")
    IniWrite($INI, "Numbers", "last", 10002)
    EndIf
    ; Ende Test-INI

    [/autoit] [autoit][/autoit] [autoit]

    Global $aPatienten = IniReadSection($INI, "Patienten")
    Local $lastNum = IniRead($INI, "Numbers", "last", 9999)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 1017, 736, 267, 139)
    $PageControl1 = GUICtrlCreateTab(8, 56, 1007, 707)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Nr|Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße", 24, 152, 969, 552)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    ; ### hier Kontextmenü für ListView einfügen:
    $mnu = GUICtrlCreateContextMenu($Listview1)
    $mnu_del = GUICtrlCreateMenuItem('Patient Löschen', $mnu)
    ; ### Ende Kontextmenü
    $TabSheet2 = GUICtrlCreateTabItem("Neuer Patient")
    $Label1 = GUICtrlCreateLabel("Vorname:", 28, 105, 73, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 28, 137, 85, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 110, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 110, 137, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 28, 169, 111, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 110, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 28, 201, 106, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 110, 201, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 28, 233, 57, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 110, 233, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 110, 272, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    #EndRegion ### START Koda GUI section ### Form=

    [/autoit] [autoit][/autoit] [autoit]

    $Form2 = GUICreate('Form2')
    $edit_Patient = GUICtrlCreateEdit('', 20, 20, 250, 200)

    [/autoit] [autoit][/autoit] [autoit]

    _FillListView()
    GUISetState(@SW_SHOW, $Form1)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; Window-Handle
    Case $Form1
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    Exit
    Case $PageControl1
    If GUICtrlRead($PageControl1) = 0 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 1 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 2 Then

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    $lastNum += 1
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite($INI, "Numbers", "last", $lastNum)
    IniWrite($INI, "Patienten", $lastNum, $Vorname & '|' & $Nachname & '|' & $Geburtsdatum & '|' & $PLZWohnort & '|' & $Strasse)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "DD.MM.YYYY")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    _FillListView()
    Case $mnu_del
    ; Eintrag aus INI löschen:
    $index = _GUICtrlListView_GetSelectedIndices($Listview1)
    $del_Key = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $index, 0)
    IniDelete($INI, "Patienten", $del_key)
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    ; entfernt Eintrag aus Liste:
    _GUICtrlListView_DeleteItemsSelected($Listview1)
    EndSwitch
    Case $Form2
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    ;~ Case ....

    EndSwitch
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _FillListView()
    _GUICtrlListView_DeleteAllItems($Listview1)
    If $lastNum = 9999 Then Return
    For $i = 1 To UBound($aPatienten) -1
    GUICtrlCreateListViewItem($aPatienten[$i][0] & '|' & $aPatienten[$i][1], $Listview1)
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _LeftDblClick($Info) ; Inhalt der angeklickten Zeile (alle Spalten) wird in GUI gezeigt
    Local $indx_Item = $Info[3], $sShow = ''
    For $i = 0 To 4
    $sShow &= _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $indx_Item, $i) & @CRLF
    Next
    GUICtrlSetData($edit_Patient, $sShow)
    GUISetState(@SW_SHOW, $Form2)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $ListView1
    If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hWndListView
    Switch $iCode
    Case $LVN_COLUMNCLICK ; A column was clicked
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ColumnClick($aInfo)
    Case $LVN_DELETEITEM ; An item is about to be deleted
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ItemDeleted($aInfo)
    Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    Return 0 ; allow the list view to perform its normal track select processing.
    ;Return 1 ; the item will not be selected.
    ;~ _HottTrackItem($aInfo)
    Case $LVN_KEYDOWN ; A key has been pressed
    Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
    Local $aInfo[5] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "VKey"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _KeyDown($aInfo)
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _LeftClick($aInfo)
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    _LeftDblClick($aInfo)
    Case $NM_KILLFOCUS ; The control has lost the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _LostFocus($aInfo)
    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ; Return 1 ; not to allow the default processing
    Return $GUI_RUNDEFMSG ; allow the default processing
    ;~ _RightClick($aInfo)
    Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _RightDblClick($aInfo)
    Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _InputFocusReturn($aInfo)
    Case $NM_SETFOCUS ; The control has received the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _SetFocus($aInfo)
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]
  • ;) okay danke
    ich hab mal das 2. GUI ausgebaut. Wie kann ich jetzt die Daten in den Inputfeldern Anzeigen lassen?

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    Local $INI = @ScriptDir & "\Patienten.ini"

    [/autoit] [autoit][/autoit] [autoit]

    ; nur zum Testen:
    If Not FileExists($INI) Then
    IniWrite($INI, "Patienten", 10000, "Peter|Lustig|11.11.1956|12345 Grüner-Wald|Bauwagen 1")
    IniWrite($INI, "Patienten", 10001, "Marion|Rosenbaum|08.12.1987|33445 Irgendwo|Am Feld 35")
    IniWrite($INI, "Patienten", 10002, "Max|Mustermann|12.12.1978|44556 Musterdorf|Mustergasse 17")
    IniWrite($INI, "Numbers", "last", 10002)
    EndIf
    ; Ende Test-INI

    [/autoit] [autoit][/autoit] [autoit]

    Global $aPatienten = IniReadSection($INI, "Patienten")
    Local $lastNum = IniRead($INI, "Numbers", "last", 9999)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 1017, 736,0,0)
    $PageControl1 = GUICtrlCreateTab(8, 56, 1007, 707)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Nr |Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße", 24, 152, 969, 552)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    ; ### hier Kontextmenü für ListView einfügen:
    $mnu = GUICtrlCreateContextMenu($Listview1)
    $mnu_del = GUICtrlCreateMenuItem('Patient Löschen', $mnu)
    ; ### Ende Kontextmenü
    $TabSheet2 = GUICtrlCreateTabItem("Neuer Patient")
    $Label1 = GUICtrlCreateLabel("Vorname:", 28, 105, 73, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 28, 137, 85, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 110, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 110, 137, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 28, 169, 111, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 110, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 28, 201, 106, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 110, 201, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 28, 233, 57, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 110, 233, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 110, 272, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    #EndRegion ### START Koda GUI section ### Form=

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 1018, 737,0,0)
    $Edit1 = GUICtrlCreateEdit("", 16, 80, 985, 569)
    $Label6 = GUICtrlCreateLabel("Nr.:", 16, 32, 21, 17)
    $Label7 = GUICtrlCreateLabel("Vorname:", 88, 32, 49, 17)
    $Label8 = GUICtrlCreateLabel("Nachname:", 272, 32, 59, 17)
    $Label9 = GUICtrlCreateLabel("Geburtsdatum:", 464, 32, 73, 17)
    $Label10 = GUICtrlCreateLabel("PLZ / Wohnort:", 616, 32, 79, 17)
    $Label11 = GUICtrlCreateLabel("Straße:", 840, 32, 38, 17)
    $Input6 = GUICtrlCreateInput("", 40, 32, 41, 21)
    $Input7 = GUICtrlCreateInput("", 144, 32, 121, 21)
    $Input8 = GUICtrlCreateInput("", 336, 32, 121, 21)
    $Input9 = GUICtrlCreateInput("", 544, 32, 65, 21)
    $Input10 = GUICtrlCreateInput("", 696, 32, 137, 21)
    $Input11 = GUICtrlCreateInput("", 880, 32, 121, 21)
    $Button2 = GUICtrlCreateButton("Neuer Eintrag", 16, 664, 121, 57, 0)
    $Button3 = GUICtrlCreateButton("Daten speichern", 144, 664, 121, 57, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _FillListView()
    GUISetState(@SW_SHOW, $Form1)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; Window-Handle
    Case $Form1
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    Exit
    Case $PageControl1
    If GUICtrlRead($PageControl1) = 0 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 1 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 2 Then

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    $lastNum += 1
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite($INI, "Numbers", "last", $lastNum)
    IniWrite($INI, "Patienten", $lastNum, $Vorname & '|' & $Nachname & '|' & $Geburtsdatum & '|' & $PLZWohnort & '|' & $Strasse)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "DD.MM.YYYY")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    _FillListView()
    Case $mnu_del
    ; Eintrag aus INI löschen:
    $index = _GUICtrlListView_GetSelectedIndices($Listview1)
    $del_Key = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $index, 0)
    IniDelete($INI, "Patienten", $del_key)
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    ; entfernt Eintrag aus Liste:
    _GUICtrlListView_DeleteItemsSelected($Listview1)
    EndSwitch
    Case $Form2
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    ;~ Case ....
       
    EndSwitch
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _FillListView()
    _GUICtrlListView_DeleteAllItems($Listview1)
    If $lastNum = 9999 Then Return
    For $i = 1 To UBound($aPatienten) -1
    GUICtrlCreateListViewItem($aPatienten[$i][0] & '|' & $aPatienten[$i][1], $Listview1)
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _LeftDblClick($Info) ; Inhalt der angeklickten Zeile (alle Spalten) wird in GUI gezeigt
    Local $indx_Item = $Info[3], $sShow = ''
    For $i = 0 To 4
    $sShow &= _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $indx_Item, $i) & @CRLF
    Next
    GUICtrlSetData($Edit1, $sShow)
    GUISetState(@SW_SHOW, $Form2)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $ListView1
    If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hWndListView
    Switch $iCode
    Case $LVN_COLUMNCLICK ; A column was clicked
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ColumnClick($aInfo)
    Case $LVN_DELETEITEM ; An item is about to be deleted
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ItemDeleted($aInfo)
    Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    Return 0 ; allow the list view to perform its normal track select processing.
    ;Return 1 ; the item will not be selected.
    ;~ _HottTrackItem($aInfo)
    Case $LVN_KEYDOWN ; A key has been pressed
    Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
    Local $aInfo[5] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "VKey"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _KeyDown($aInfo)
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _LeftClick($aInfo)
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    _LeftDblClick($aInfo)
    Case $NM_KILLFOCUS ; The control has lost the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _LostFocus($aInfo)
    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ; Return 1 ; not to allow the default processing
    Return $GUI_RUNDEFMSG ; allow the default processing
    ;~ _RightClick($aInfo)
    Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _RightDblClick($aInfo)
    Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _InputFocusReturn($aInfo)
    Case $NM_SETFOCUS ; The control has received the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _SetFocus($aInfo)
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]
    • Offizieller Beitrag

    Guckst du:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    Local $INI = @ScriptDir & "\Patienten.ini"

    [/autoit] [autoit][/autoit] [autoit]

    ; nur zum Testen:
    If Not FileExists($INI) Then
    IniWrite($INI, "Patienten", 10000, "Peter|Lustig|11.11.1956|12345 Grüner-Wald|Bauwagen 1")
    IniWrite($INI, "Patienten", 10001, "Marion|Rosenbaum|08.12.1987|33445 Irgendwo|Am Feld 35")
    IniWrite($INI, "Patienten", 10002, "Max|Mustermann|12.12.1978|44556 Musterdorf|Mustergasse 17")
    IniWrite($INI, "Numbers", "last", 10002)
    EndIf
    ; Ende Test-INI

    [/autoit] [autoit][/autoit] [autoit]

    Global $aPatienten = IniReadSection($INI, "Patienten")
    Local $lastNum = IniRead($INI, "Numbers", "last", 9999)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 1017, 736,0,0)
    $PageControl1 = GUICtrlCreateTab(8, 56, 1007, 707)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Nr |Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße", 24, 152, 969, 552)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    ; ### hier Kontextmenü für ListView einfügen:
    $mnu = GUICtrlCreateContextMenu($Listview1)
    $mnu_del = GUICtrlCreateMenuItem('Patient Löschen', $mnu)
    ; ### Ende Kontextmenü
    $TabSheet2 = GUICtrlCreateTabItem("Neuer Patient")
    $Label1 = GUICtrlCreateLabel("Vorname:", 28, 105, 73, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 28, 137, 85, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 110, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 110, 137, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 28, 169, 111, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 110, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 28, 201, 106, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 110, 201, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 28, 233, 57, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 110, 233, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 110, 272, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    #EndRegion ### START Koda GUI section ### Form=

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 1018, 737,0,0)
    $Edit1 = GUICtrlCreateEdit("", 16, 80, 985, 569)
    $Label6 = GUICtrlCreateLabel("Nr.:", 16, 32, 21, 17)
    $Label7 = GUICtrlCreateLabel("Vorname:", 88, 32, 49, 17)
    $Label8 = GUICtrlCreateLabel("Nachname:", 272, 32, 59, 17)
    $Label9 = GUICtrlCreateLabel("Geburtsdatum:", 464, 32, 73, 17)
    $Label10 = GUICtrlCreateLabel("PLZ / Wohnort:", 616, 32, 79, 17)
    $Label11 = GUICtrlCreateLabel("Straße:", 840, 32, 38, 17)
    $Input6 = GUICtrlCreateInput("", 40, 32, 41, 21)
    $Input7 = GUICtrlCreateInput("", 144, 32, 121, 21)
    $Input8 = GUICtrlCreateInput("", 336, 32, 121, 21)
    $Input9 = GUICtrlCreateInput("", 544, 32, 65, 21)
    $Input10 = GUICtrlCreateInput("", 696, 32, 137, 21)
    $Input11 = GUICtrlCreateInput("", 880, 32, 121, 21)
    $Button2 = GUICtrlCreateButton("Neuer Eintrag", 16, 664, 121, 57, 0)
    $Button3 = GUICtrlCreateButton("Daten speichern", 144, 664, 121, 57, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _FillListView()
    GUISetState(@SW_SHOW, $Form1)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; Window-Handle
    Case $Form1
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    Exit
    Case $PageControl1
    If GUICtrlRead($PageControl1) = 0 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 1 Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf GUICtrlRead($PageControl1) = 2 Then

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    $lastNum += 1
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite($INI, "Numbers", "last", $lastNum)
    IniWrite($INI, "Patienten", $lastNum, $Vorname & '|' & $Nachname & '|' & $Geburtsdatum & '|' & $PLZWohnort & '|' & $Strasse)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "DD.MM.YYYY")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    _FillListView()
    Case $mnu_del
    ; Eintrag aus INI löschen:
    $index = _GUICtrlListView_GetSelectedIndices($Listview1)
    $del_Key = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $index, 0)
    IniDelete($INI, "Patienten", $del_key)
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    ; entfernt Eintrag aus Liste:
    _GUICtrlListView_DeleteItemsSelected($Listview1)
    EndSwitch
    Case $Form2
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    ;~ Case ....

    EndSwitch
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _FillListView()
    _GUICtrlListView_DeleteAllItems($Listview1)
    If $lastNum = 9999 Then Return
    For $i = 1 To UBound($aPatienten) -1
    GUICtrlCreateListViewItem($aPatienten[$i][0] & '|' & $aPatienten[$i][1], $Listview1)
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _LeftDblClick($Info) ; Inhalt der angeklickten Zeile (alle Spalten) wird in GUI gezeigt
    GUICtrlSetData($Input6 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 0))
    GUICtrlSetData($Input7 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 1))
    GUICtrlSetData($Input8 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 2))
    GUICtrlSetData($Input9 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 3))
    GUICtrlSetData($Input10 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 4))
    GUICtrlSetData($Input11 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 5))
    GUISetState(@SW_SHOW, $Form2)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $ListView1
    If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hWndListView
    Switch $iCode
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    _LeftDblClick($aInfo)
    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
    Return $GUI_RUNDEFMSG ; allow the default processing
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]
  • wollte mal für dich ver schöner aber leider habe ich jetzt bug drin^^

    hier kannst dir das bild mal an schauen

    http://s11b.directupload.net/file/d/1629/857rdjev_jpg.htm

    ps schreibt mir mal bitte wo der fehler war und zeigt mir mal das ich auch weiter lernen kann ^^

    Spoiler anzeigen

    #cs ----------------------------------------------------------------------------
    AutoIt Version: 3.2.10.0
    Author: Sirocool

    Script Function:
    Template AutoIt script.
    #ce ----------------------------------------------------------------------------

    ; Script Start - Add your code below here
    Dim $ver = "1.0.0"
    #include <Inet.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    If FileExists("C:\artzt\images\bg.bmp") Then
    _Haupt()
    Else
    DirCreate("C:\artzt\images\")
    FileInstall("images\Close.bmp","C:\artzt\images\close.bmp")
    FileInstall("images\bg.bmp","C:\artzt\images\bg.bmp")
    Sleep(500)
    _Haupt()
    EndIf
    Func _Haupt()
    $Form1 = GUICreate("Artzt v.1.0.0", 900, 600, -1, -1,$WS_POPUP)
    GUISetBkColor("C:\artzt\images\bg.gif")
    $Pic6 = GUICtrlCreatePic("C:\artzt\images\close.bmp", 858, 0, 42, 40, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetCursor (-1, 0)
    $Pic7 = GUICtrlCreatePic("C:\artzt\images\bg.bmp", 0, 0, 900, 600, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS,$WS_DISABLED))
    $PageControl1 = GUICtrlCreateTab(8, 56, 900, 600)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Patienten")
    $Listview1 = GUICtrlCreateListView("Nr|Vorname|Nachname|Geburtsdatum|PLZ / Wohnort| Straße", 340, 361, 559, 200)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    ; ### hier Kontextmenü für ListView einfügen:
    $mnu = GUICtrlCreateContextMenu($Listview1)
    $mnu_del = GUICtrlCreateMenuItem('Patient Löschen', $mnu)
    ; ### Ende Kontextmenü
    $Label1 = GUICtrlCreateLabel("Vorname:", 345, 105, 73, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Nachname:", 600, 105, 85, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 420, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 700, 105, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Geburtsdatum:", 345, 169, 111, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("DD.MM.YYYY", 420, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("PLZ / Wohnort:", 600, 169, 106, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 700, 169, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Straße:", 345, 233, 57, 24)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 420, 233, 161, 22)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neuen Patienten speichern", 700, 233, 161, 30, 0)
    GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
    $TabSheet3 = GUICtrlCreateTabItem("Termine")
    GUICtrlCreateTabItem("")
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
    GUISetState(@SW_SHOW)

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; Window-Handle
    Case $Form1
    Switch $nMsg[0] ; Event
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Pic6
    _AnimButton($Form1, $Pic6)
    _Close()
    Case $PageControl1
    If GUICtrlRead($PageControl1) = 0 Then

    ElseIf GUICtrlRead($PageControl1) = 1 Then

    ElseIf GUICtrlRead($PageControl1) = 2 Then

    EndIf
    Case $Button1
    $lastNum += 0
    $Vorname = GUICtrlRead($Input1)
    $Nachname = GUICtrlRead($Input2)
    $Geburtsdatum = GUICtrlRead($Input3)
    $PLZWohnort = GUICtrlRead($Input4)
    $Strasse = GUICtrlRead($Input5)
    IniWrite($INI, "Numbers", "last", $lastNum)
    IniWrite($INI, "Patienten", $lastNum, $Vorname & '|' & $Nachname & '|' & $Geburtsdatum & '|' & $PLZWohnort & '|' & $Strasse)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "DD.MM.YYYY")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    Case $mnu_del
    ; Eintrag aus INI löschen:
    $index = _GUICtrlListView_GetSelectedIndices($Listview1)
    $del_Key = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $index, 0)
    IniDelete($INI, "Patienten", $del_key)
    ; Array mit Patienten-Daten neu einlesen
    $aPatienten = IniReadSection($INI, "Patienten")
    ; entfernt Eintrag aus Liste:
    _GUICtrlListView_DeleteItemsSelected($Listview1)
    EndSwitch
    EndSwitch
    WEnd


    _GUICtrlListView_DeleteAllItems($Listview1)
    If $lastNum = 9999 Then Return
    For $i = 1 To UBound($aPatienten) -1
    GUICtrlCreateListViewItem($aPatienten[$i][0] & '|' & $aPatienten[$i][1], $Listview1)
    Next
    EndFunc

    Func _LeftDblClick($Info) ; Inhalt der angeklickten Spalte wird in GUI gezeigt
    Local $indx_Item = $Info[3], $indx_Sub = $Info[4]
    GUICtrlSetData($lb_Patient, _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $indx_Item, $indx_Sub))
    GUISetState(@SW_SHOW, $Form2)
    EndFunc

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $ListView1
    If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hWndListView
    Switch $iCode
    Case $LVN_COLUMNCLICK ; A column was clicked
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ColumnClick($aInfo)
    Case $LVN_DELETEITEM ; An item is about to be deleted
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    ;~ _ItemDeleted($aInfo)
    Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Local $aInfo[11] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "Param")]
    Return 0 ; allow the list view to perform its normal track select processing.
    ;Return 1 ; the item will not be selected.
    ;~ _HottTrackItem($aInfo)
    Case $LVN_KEYDOWN ; A key has been pressed
    Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
    Local $aInfo[5] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "VKey"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _KeyDown($aInfo)
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _LeftClick($aInfo)
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    _LeftDblClick($aInfo)
    Case $NM_KILLFOCUS ; The control has lost the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _LostFocus($aInfo)
    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ; Return 1 ; not to allow the default processing
    Return 0 ; allow the default processing
    ;~ _RightClick($aInfo)
    Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    ;~ _RightDblClick($aInfo)
    Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _InputFocusReturn($aInfo)
    Case $NM_SETFOCUS ; The control has received the input focus
    Local $aInfo[3] = [$hWndFrom, _
    $iIDFrom, _
    $iCode]
    ;~ _SetFocus($aInfo)
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    Exit
    Func _AnimButton($IDgui, $IDbtn, $delay=100);Animiert bilder als button, funktion an sich von BugFix
    Local $pos = ControlGetPos($IDgui, '', $IDbtn)
    Local $pWin = WinGetPos($IDgui)
    ControlMove($IDgui, '', $IDbtn, $pos[0], $pos[1]+2, $pos[2]-2, $pos[3]-2)
    Sleep($delay)
    ControlMove($IDgui, '', $IDbtn, $pos[0], $pos[1], $pos[2], $pos[3])
    EndFunc ;==> _AnimButton

    3 Mal editiert, zuletzt von Sirocool (30. November 2008 um 13:20)

    • Offizieller Beitrag

    Des Script läßt sich schonmal nicht Compilen , nur Fehlermeldungen . In deiner Rar fehlen auch die Datei/en im IMAGES Unterverzeichnis .

  • Des Script läßt sich schonmal nicht Compilen , nur Fehlermeldungen . In deiner Rar fehlen auch die Datei/en im IMAGES Unterverzeichnis .

    du musst die image bilder unter C:\artzt\images mit rein machen dann müsste es gehn

    Einmal editiert, zuletzt von Sirocool (30. November 2008 um 13:35)

    • Offizieller Beitrag

    Sehr witzig, wenn du in der 1. Rar die Images net drin hast dann kann ich die auch nicht nutzen. Des Script kann aber auch nicht laufen weil z.B. deine Func _close im Script nicht definiert wird aber du sie aufrufst . Schau mal ob du vielleicht ne falsche Version in deine RAR gepackt hast .

  • und in der rar ist doch images drin und func close habe ich jetzt mit drin in zeile 128 sorry

    also bei mir sit es so auch wwenn ich es runterladen tuhe so wie oben beim bildlink

    nur das jetzt schon mal mit exit geht

    wie gesagt wollte es nur etwas verschönern^^