MsgBoxEx Problem

  • Hier erstmal Skript :

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    _MsgBoxEx("Test","Hallo",1,"OK|OK2")
    Func _MsgBoxEx($Title,$Text,$Buttons = 1,$Buttons_Names = "OK",$Color = 0xCCCCCC)
    If Not IsNumber($Buttons) Then
    SetError(@error,2)
    Return 0
    EndIf
    $GUI_MSGBOX=GUICreate($Title,($Buttons*100)+100,100)
    GUISetState()
    GUISetBkColor($Color)
    $Buttons_Splitted=StringSplit($Buttons_Names,"|")
    $PosButts=0
    Dim $Buttons_Create[$Buttons_Splitted[0]+1]
    For $i=1 to Ubound($Buttons_Splitted,1)-1
    $Buttons_Create[$i]=GUICtrlCreateButton($Buttons_Splitted[$i],$PosButts,100-25,100)
    $PosButts=$PosButts+100
    Next
    $Edit=GUICtrlCreateEdit($Text,0,0,($Buttons*100)+98,70,$ES_READONLY+$WS_VSCROLL)
    While 1
    $msg=GUIGetMsg()
    Select
    Case $msg=$GUI_EVENT_CLOSE
    SetError(@error,1)
    Return 0
    For $i=1 to Ubound($Buttons_Create,1)-1
    Case $msg=$Buttons_Create[$i]
    GUIDelete($GUI_MSGBOX)
    Return 1
    Next
    EndSelect
    WEnd
    EndFunc

    [/autoit]


    Mit diesem Befehl soll man soviel Buttons in einer MsgBox erstellen können wie man will und diese auch beschriften wie man will.Doch nun stellt sich ein Problem.
    Zeile 28 : (28) : ==> "Case" statement with no matching "Select"or "Switch" statement.:
    Case $msg=$Buttons_Create[$i]
    Hoffe ihr könnt mir helfen

    mfg nof@ker :thumbup:

  • Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    _MsgBoxEx("Test", "Hallo", 1, "OK|OK2")

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

    Func _MsgBoxEx($Title, $Text, $Buttons = 1, $Buttons_Names = "OK", $Color = 0xCCCCCC)
    If Not IsNumber($Buttons) Then
    SetError(@error, 2)
    Return 0
    EndIf
    $GUI_MSGBOX = GUICreate($Title, ($Buttons * 100) + 100, 100)
    GUISetState()
    GUISetBkColor($Color)
    $Buttons_Splitted = StringSplit($Buttons_Names, "|")
    $PosButts = 0
    Dim $Buttons_Create[$Buttons_Splitted[0] + 1]
    For $i = 1 To UBound($Buttons_Splitted, 1) - 1
    $Buttons_Create[$i] = GUICtrlCreateButton($Buttons_Splitted[$i], $PosButts, 100 - 25, 100)
    $PosButts = $PosButts + 100
    Next
    $Edit = GUICtrlCreateEdit($Text, 0, 0, ($Buttons * 100) + 98, 70, $ES_READONLY + $WS_VSCROLL)
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    SetError(@error, 1)
    Return 0
    For $i = 1 To UBound($Buttons_Create, 1) - 1
    Select
    Case $msg = $Buttons_Create[$i]
    GUIDelete($GUI_MSGBOX)
    Return 1
    EndSelect
    Next
    EndSelect
    WEnd
    EndFunc ;==>_MsgBoxEx

    [/autoit]
  • @nof@ker2: Das war das was ich mich auch gerade gefragt habe: wie wird auf ein Button-Click reagiert?

    Aber das kommt sicherlich noch ;)

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Hi!

    Ich hab hier nur einen Ansatz. Ist nicht wirklich sauber gelöst. Kommt auf den Zufall an ob die Variable $i gerade die Buttonnummer hat wenn man darauf klickt.

    Spoiler anzeigen
    [autoit]


    #include <GuiConstantsEx.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    _MsgBoxEx("Test","Hallo",2,"OK|OK2|ok")
    Func _MsgBoxEx($Title,$Text,$Buttons = 1,$Buttons_Names = "OK",$Color = 0xCCCCCC)
    If Not IsNumber($Buttons) Then
    SetError(@error,2)
    Return 0
    EndIf
    $GUI_MSGBOX=GUICreate($Title,($Buttons*100)+100,100)
    GUISetState()
    GUISetBkColor($Color)
    $Buttons_Splitted=StringSplit($Buttons_Names,"|")
    $PosButts=0
    Dim $Buttons_Create[$Buttons_Splitted[0]+1]
    For $i=1 to Ubound($Buttons_Splitted,1)-1
    $Buttons_Create[$i]=GUICtrlCreateButton($Buttons_Splitted[$i],$PosButts,100-25,100)
    $PosButts=$PosButts+100
    Next
    $Edit=GUICtrlCreateEdit($Text,0,0,($Buttons*100)+98,70,$ES_READONLY+$WS_VSCROLL)
    Dim $i = 1
    While 1
    $msg=GUIGetMsg()
    Select
    Case $msg=$GUI_EVENT_CLOSE
    SetError(@error,1)
    Return 0
    Case $msg=$Buttons_Create[$i]
    GUIDelete($GUI_MSGBOX)
    Return 1
    case Else
    If $i >= Ubound($Buttons_Create,1)-1 Then
    $i = 0
    EndIf
    $i += 1
    Sleep(100)
    ConsoleWrite($i)
    EndSelect
    WEnd
    EndFunc

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

    Hier eine Doppelklickvariante.

    Spoiler anzeigen
    [autoit]


    #include <GuiConstantsEx.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    _MsgBoxEx("Test","Hallo",5,"OK|OK2|ok|asdf|yxcv|dsfsdf")
    Func _MsgBoxEx($Title,$Text,$Buttons = 1,$Buttons_Names = "OK",$Color = 0xCCCCCC)
    If Not IsNumber($Buttons) Then
    SetError(@error,2)
    Return 0
    EndIf
    $GUI_MSGBOX=GUICreate($Title,($Buttons*100)+100,100)
    GUISetState()
    GUISetBkColor($Color)
    $Buttons_Splitted=StringSplit($Buttons_Names,"|")
    $PosButts=0
    Dim $Buttons_Create[$Buttons_Splitted[0]+1]
    For $i=1 to Ubound($Buttons_Splitted,1)-1
    $Buttons_Create[$i]=GUICtrlCreateButton($Buttons_Splitted[$i],$PosButts,100-25,100)
    $PosButts=$PosButts+100
    Next
    $Edit=GUICtrlCreateEdit($Text,0,0,($Buttons*100)+98,70,$ES_READONLY+$WS_VSCROLL)
    Dim $i = 1
    While 1
    $msg=GUIGetMsg()
    Select
    Case $msg=$GUI_EVENT_CLOSE
    SetError(@error,1)
    Return 0
    Case $msg=$Buttons_Create[$i]
    GUIDelete($GUI_MSGBOX)
    Return 1
    Case Else
    If $msg > 1 Then
    $i = $msg -2
    EndIf
    EndSelect
    WEnd
    EndFunc

    [/autoit]

    If not :?: then ?( else :thumbup:

    Einmal editiert, zuletzt von Concara (28. April 2009 um 18:10)