MsgBox - Eigene Beschriftung

  • Hey,
    wie kann ich denn einstellen, dass bei einer MessageBox meine eigenen Buttons kommen ?(
    Also dass ich selber die Namen wählen kann und dann z.B.:

    [autoit]


    $x = MsgBox(12345,"Bla", "BlaBla")
    If $x = Warum? Then MsgBox(64, "Weil", "es einfach halt so ist xD")
    EndIf

    [/autoit]

    Viele Grüße,
    HopFail

    Einmal editiert, zuletzt von HopFail (21. November 2009 um 18:34)

  • Mach dir einfach eine kleine GUI.
    Die Buttons belegst du mit Funktinen oder Rückgabewerten.

    Fertig :D

    Edit:
    Zu langsam ;(

  • [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Fehler", 221, 119, 465, 342)
    $Label1 = GUICtrlCreateLabel("Es ist ein Fehler aufgetreten !", 16, 24, 141, 17)
    $Label2 = GUICtrlCreateLabel("Wollen Sie das Programm neustarten?", 16, 48, 184, 17)
    $Button1 = GUICtrlCreateButton("Ja, sofort!", 16, 80, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Bloß nicht!", 128, 80, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]

    Beispiel für eine Fehler Msg Box.

    Gut die sieht noch nicht 100 % aus.
    Aber das kann man alles machen :rolleyes:

  • Spoiler anzeigen

    Ich glaub ich muss mir das mit den GUI's mal lange anschauen, habe aber heute keine Zeit mehr, muss ja langsam ins Bett (ok morgen haben wir zur 3.^^)

    Viele Grüße,
    HopFail

  • Oder so:

    Spoiler anzeigen
    [autoit]


    _MsgBox("Titel","Test","der MsgBox","Okaaay","Erbrechen")

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

    Func _MsgBox($title="",$TExt1="",$Textl2="",$BtText1="",$BtText2="")
    ;Rückgabewerte: -1=Auf X gedrückt, 1=Erster Button,2=Zweiter Button
    ;L3viathan2142
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate($title, 221, 119, 465, 342)
    $Label1 = GUICtrlCreateLabel($TExt1, 16, 24, 141, 17)
    $Label2 = GUICtrlCreateLabel($TExt2, 16, 48, 184, 17)
    $Button1 = GUICtrlCreateButton($BtTExt1, 16, 80, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton($BTTExt2, 128, 80, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Return -1
    Case $Button1
    Return 1
    Case $Button2
    Return 2
    EndSwitch
    WEnd
    EndFunc

    [/autoit]

    Twitter: @L3viathan2142
    Benutze AutoIt persönlich nicht mehr, da ich keinen Windows-Rechner mehr besitze.

  • Hallo du kannst auch folgendes machen:

    Spoiler anzeigen
    [autoit]


    Func _MsgBoxIndividual($flag, $title, $text, $btn_text1 = "&OK", $btn_text2 = "&Nein", $btn_text3 = "&Vielleicht", $TimeOut = 0)
    Local $str = "Local $x = Opt('WinWaitDelay',50)+WinWait('" & $title & "','')+" & _
    "ControlSetText('" & $title & "','" & $text & "','Button1','" & $btn_text1 & "')+" & _
    "ControlSetText('" & $title & "','" & $text & "','Button2','" & $btn_text2 & "')+" & _
    "ControlSetText('" & $title & "','" & $text & "','Button3','" & $btn_text3 & "')"
    Run('"' & @AutoItExe & '" /AutoIt3ExecuteLine "' & $str & '"')
    Sleep(100)
    Return MsgBox($flag, $title, $text, $TimeOut)
    EndFunc ;==>_MsgBoxIndividual
    _MsgBoxIndividual(34, "Frage", "Gehst du heute mit mir aus?", "&Bin dabei", "&Mag nicht")

    [/autoit]


    siehe dazu auch MsgBox-Buttons Text ändern mal anders :) von funkey

    mfg (Auto)Bert