Problem mit Gui

  • Ich brauche mal wieder eure Hilfe,

    ich will mit meiner Gui meine geplante Zeit von Aufgaben in einer Excel speichern, dass klappt auch so weit.

    Mein Problem ist aber, dass sich mit den UPdown Buttons oder per Eingabe direkt ins Input, die Restzeit aktualieren soll.
    Mit den UPdown habe ich hinbekommen, aber jetzt kann ich nicht manuell eingeben.
    Ausserdem will ich mir das so machen, das mit den UPdown, höchstens die Zeit eingegebne kann, die ich auch geplant habe.

    Wäre nett wenn ein Fortgeschrittener oder Pro mir mal kurz helfen kann....


    Spoiler anzeigen

    #include <Date.au3>
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>
    #include <Excel.au3>
    #include <Array.au3>
    #include <UpdownConstants.au3>


    Global $Restzeitstunde="03"
    Global $Restzeitmin="10"

    GUICreate("Aufgaben Planung", 624, 340, -1, -1)
    GUISetBkColor(0xC0C0C0)
    GUICtrlCreateLabel("Wieviel Zeit hast du gebraucht ?", 3, 95, 610, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $maxh = GUICtrlCreateInput($Restzeitstunde, 235, 10, 50, 40, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
    GUICtrlSetFont(-1, 23, 400, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetCursor (-1, 7)
    GUICtrlCreateLabel(":", 295, 5, 14, 54)
    GUICtrlSetFont(-1, 30, 400, 0)
    $maxm = GUICtrlCreateInput($Restzeitmin, 315, 10, 50, 40, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
    GUICtrlSetFont(-1, 23, 400, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetCursor (-1, 7)
    $input = GUICtrlCreateInput("", 200, 140, 95, 66, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
    GUICtrlSetData(-1,"00")
    GUICtrlSetFont(-1, 30, 400, 0)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetLimit(-1, 2)
    $uzupdownh1=GUICtrlCreateUpdown(-1,$UDS_ALIGNLEFT)
    GUICtrlSetLimit($uzupdownh1,$Restzeitstunde,00)
    GUICtrlCreateLabel(":", 300, 140, 14, 54)
    GUICtrlSetFont(-1, 35, 400, 0)
    $input2 = GUICtrlCreateInput("00", 320, 140, 95, 66, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
    GUICtrlSetFont(-1, 30, 400, 0)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetLimit(-1, 2)
    $uzupdownmin1=GUICtrlCreateUpdown(-1,$UDS_ALIGNRIGHT)
    GUICtrlSetLimit($uzupdownmin1,59,00)
    $eintragen = GUICtrlCreateButton("Übernehmen", 200, 250, 225, 41, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))
    GUICtrlSetFont(-1, 12, 400, 0)
    GUICtrlSetCursor (-1, 0)

    GUISetState(@SW_SHOW)
    While 1
    $iMax = ($Restzeitstunde*60)+$Restzeitmin
    $time = (GUICtrlRead($input)*60)+GUICtrlRead($input2)
    GUICtrlSetData($input, StringFormat('%02i', Int($time / 60)))
    GUICtrlSetData($input2, StringFormat('%02i', Mod($time, 60)))
    $rt=$iMax-((GUICtrlRead($input)*60)+GUICtrlRead($input2))
    GUICtrlSetData($maxh, StringFormat('%02i',Int($rt / 60) ))
    GUICtrlSetData($maxm,StringFormat('%02i', Mod($rt, 60)))

    $nMsg = GUIGetMsg()
    Switch GUIGetMsg()

    Case $GUI_EVENT_CLOSE
    Exit

    Case $eintragen
    Exit; normalerweise ist hier func zur Eintragung in Excel
    EndSwitch
    WEnd

  • Hallo billemg,

    dadurch dass du di Berechnungen direkt in der while Schleife ausführst wird durch das ständige Aktualisieren eine Änderung unmöglich. Führe die Berechnungen nur aus wenn sich etwas geändert hat, dann sollte es klappen:

    Spoiler anzeigen
    [autoit]

    While 1

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

    $nMsg = GUIGetMsg()
    Switch GUIGetMsg()
    Case $uzupdownh1, $uzupdownmin1, $input, $input2
    $iMax = ($Restzeitstunde * 60) + $Restzeitmin
    $time = (GUICtrlRead($input) * 60) + GUICtrlRead($input2)
    GUICtrlSetData($input, StringFormat('%02i', Int($time / 60)))
    GUICtrlSetData($input2, StringFormat('%02i', Mod($time, 60)))
    $rt = $iMax - ((GUICtrlRead($input) * 60) + GUICtrlRead($input2))
    GUICtrlSetData($maxh, StringFormat('%02i', Int($rt / 60)))
    GUICtrlSetData($maxm, StringFormat('%02i', Mod($rt, 60)))

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

    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $eintragen
    Exit; normalerweise ist hier func zur Eintragung in Excel
    EndSwitch
    WEnd

    [/autoit]

    mfg (Auto)Bert