Button nicht klickbar

  • Hi,

    habe folgendes Script:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListBox.au3>
    #include <ListBoxConstants.au3>
    #include <WindowsConstants.au3>

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

    GUICreate("Softwareinfo", 500, 400)
    $programminfo = GUICtrlCreateLabel("", 260, 4, 228, 80)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    $programmliste = GUICtrlCreateList("", 4, 4, 250, 395)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    $programme = IniReadSectionNames("programm.ini")
    For $i = 1 To $programme[0]
    GUICtrlSetData($programmliste, $programme[$i])
    Next

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

    $lizenzfile = GUICtrlCreateButton("Lizenzfile", 260, 4)
    GUICtrlSetState($lizenzfile, $GUI_DISABLE)
    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    Global $hList = GUICtrlGetHandle($programmliste)
    Global $sItem = ""

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

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    ;~ Case $lizenzfile
    ;~ MsgBox(0, "", "Lizenzfile")
    EndSelect
    WEnd

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

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($hList)
    $hWndFrom = $ilParam
    $iCode = BitShift($iwParam, 16)
    Switch $hWndFrom
    Case $hList, $hWndList
    Switch $iCode
    Case $LBN_SELCHANGE
    $sCurrent = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    If $sCurrent <> $sItem Then
    $sItem = $sCurrent
    GUICtrlSetState($lizenzfile, $GUI_ENABLE)

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

    $programmfirma = IniRead("programm.ini", $sItem, "Firma", "")
    $programmversion = IniRead("programm.ini", $sItem, "Version", "")

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

    $programmlizenzart = IniRead("programm.ini", $sItem, "Lizenzart", "")
    $programmlizenzanzahl = IniRead("programm.ini", $sItem, "Anzahl", "")

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

    $programmtext = "Firma: " & $programmfirma & @CRLF & "Version: " & $programmversion & @CRLF & @CRLF & "Lizenzart: " & $programmlizenzart & @CRLF & "Anzahl: " & $programmlizenzanzahl

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

    If $programmlizenzart = "Netzwerk" Then
    $programmserver = IniRead("programm.ini", $sItem, "Server", "")
    $programmtext = $programmtext & @CRLF & "Lizenzserver: " & $programmserver
    GUICtrlSetPos($programminfo, 260, 4, 228, 96)

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

    If IniRead("programm.ini", $sItem, "Dongel", "") <> "" Then
    $programmtext = $programmtext & @CRLF & "Dongel"
    GUICtrlSetPos($programminfo, 260, 4, 228, 112)
    EndIf
    EndIf

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

    $programmlizenzfile = IniRead("programm.ini", $sItem, "Lizenzfile", "")
    If $programmlizenzfile <> "" Then
    $pos = ControlGetPos("Softwareinfo", "", $programminfo)
    GUICtrlSetPos($lizenzfile, 260, 4 + $pos[3] + 16)
    EndIf

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

    GUICtrlSetData($programminfo, $programmtext)
    EndIf
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]

    Das Problem ist nun wenn ich auf den Button Lizenzfile klicke die Fehlermeldung:

    Zitat

    Case $hList, $hWndList
    Case $hList, ^ ERROR

    Und wenn ich das

    Spoiler anzeigen
    [autoit]

    Case $lizenzfile
    MsgBox(0, "", "Lizenzfile")

    [/autoit]

    in wer while einkommentiere in einer Endlosschleife die Msg kommt auch wenn garnicht der Button Lizenzfile gedrückt wird. Jemand eine Idee zu den Problemen?


    P.s. Ini hochladen geht nicht also die Datei im Anhang in programm.ini umbenennen.

    Dateien

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

    3 Mal editiert, zuletzt von chip (2. Dezember 2011 um 09:16)

  • Moin,

    [autoit]

    If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($hList)

    [/autoit]


    Das kann nicht funktionieren. ;)
    So schon eher ...

    [autoit]

    If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($programmliste)

    [/autoit]


    Wobei Du schon am Anfang prüfen solltest ob $hList ein gültiges Handle ist.
    Wenn GUICtrlGetHandle($programmliste) das erste mal schon fehl schlägt, warum sollte es beim zweiten mal funktionieren ?

    Die erste Fallabfrage ist korrekt, die zweite nicht. Die wäre für einen Switch, aber nicht für Select/EndSelect.
    Also entweder

    [autoit]


    Switch (GUIGetMsg ())
    Case $lizenzfile
    MsgBox (...)
    EndSwitch

    [/autoit]

    oder

    [autoit]


    $msg = GUIGetMsg( )
    Select
    Case $msg = $lizenzfile
    MsgBox (...)
    EndSelect

    [/autoit]


    Gruß
    Greenhorn


  • Danke für die Antwort, allerdings hast du etwas überlesen ;):

    [autoit]

    Global $hList = GUICtrlGetHandle($programmliste)

    [/autoit]

    Das Script hatte ich von i2c, hab da nicht weiter groß reingeschaut.

    Das zwite stimmt zwar, ändert aber auch ncihts an der Fehlemeldung beim drücken des Buttons.

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Hi,

    das meinte ich mit:

    Zitat

    Wobei Du schon am Anfang prüfen solltest ob $hList ein gültiges Handle ist.
    Wenn GUICtrlGetHandle($programmliste) das erste mal schon fehl schlägt, warum sollte es beim zweiten mal funktionieren ?

    Sorry, undeutlich ausgedrückt. :)


    Gruß
    Greenhorn


  • Änder aber nichts an dem Problem mit den Button :). Diese erzeugt nach wie vor den Fehler:

    Case $hList, $hWndList
    Case $hList, ^ ERROR

    Es scheint so als wurde sich durch drücken des Buttons der Inhalt von $hWndList geleert.

    Edit:

    Habs nun so gemacht:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListBox.au3>
    #include <ListBoxConstants.au3>
    #include <WindowsConstants.au3>

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

    GUICreate("Softwareinfo", 500, 400)
    $programminfo = GUICtrlCreateLabel("", 260, 4, 228, 80)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    $programmliste = GUICtrlCreateList("", 4, 4, 250, 395)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    $programme = IniReadSectionNames("programm.ini")
    For $i = 1 To $programme[0]
    GUICtrlSetData($programmliste, $programme[$i])
    Next

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

    $lizenzfile = GUICtrlCreateButton("Lizenzfile", 260, 4)
    GUICtrlSetState($lizenzfile, $GUI_DISABLE)
    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    Global $hList = GUICtrlGetHandle($programmliste)
    Global $sItem = ""

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $lizenzfile
    MsgBox(0, "", "Lizenzfile")
    EndSwitch
    WEnd

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

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    $hWndFrom = $ilParam
    $iCode = BitShift($iwParam, 16)
    Switch $hWndFrom
    Case $hList
    Switch $iCode
    Case $LBN_SELCHANGE
    $sCurrent = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    If $sCurrent <> $sItem Then
    $sItem = $sCurrent
    GUICtrlSetState($lizenzfile, $GUI_ENABLE)

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

    $programmfirma = IniRead("programm.ini", $sItem, "Firma", "")
    $programmversion = IniRead("programm.ini", $sItem, "Version", "")

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

    $programmlizenzart = IniRead("programm.ini", $sItem, "Lizenzart", "")
    $programmlizenzanzahl = IniRead("programm.ini", $sItem, "Anzahl", "")

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

    $programmtext = "Firma: " & $programmfirma & @CRLF & "Version: " & $programmversion & @CRLF & @CRLF & "Lizenzart: " & $programmlizenzart & @CRLF & "Anzahl: " & $programmlizenzanzahl

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

    If $programmlizenzart = "Netzwerk" Then
    $programmserver = IniRead("programm.ini", $sItem, "Server", "")
    $programmtext = $programmtext & @CRLF & "Lizenzserver: " & $programmserver
    GUICtrlSetPos($programminfo, 260, 4, 228, 96)

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

    If IniRead("programm.ini", $sItem, "Dongel", "") <> "" Then
    $programmtext = $programmtext & @CRLF & "Dongel"
    GUICtrlSetPos($programminfo, 260, 4, 228, 112)
    EndIf
    EndIf

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

    $programmlizenzfile = IniRead("programm.ini", $sItem, "Lizenzfile", "")
    If $programmlizenzfile <> "" Then
    $pos = ControlGetPos("Softwareinfo", "", $programminfo)
    GUICtrlSetPos($lizenzfile, 260, 4 + $pos[3] + 16)
    EndIf

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

    GUICtrlSetData($programminfo, $programmtext)
    EndIf
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.