GUICtrlCreateLabel verschluckt das &-Zeichen

  • Hallo,wie der Titel schon sagt, gibt es ein Problem mit dem &
    Ich beziehe die Daten aus einer Datenbank (z.B. Firma Pleite & Co.)

    <spoiler>
    #include <GUIConstantsEx.au3>
    Local $sVariable = "A & B + C"
    MsgBox(0, "Was steht drin?", $sVariable)

    Example($sVariable)

    Func Example($sVariable)

    ; Create a GUI with various controls.
    Local $hGUI = GUICreate($sVariable)
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
    GUICtrlCreateLabel($sVariable, 100, 100)

    ; Display the GUI.GUISetState
    (@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $idOK
    ExitLoop
    EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
    EndFunc ;==>Example
    </spoiler>

    Weiß jemand Abhilfe?

  • Du musst mit StringReplace() aus '&' die Zeichenfolge '&&' machen..., soweit ich aus dem Kopf jetzt weiß.

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Moin Moin,
    hab mal n bisl in der Hilfe Datei rumgesucht und siehe da es klappt,
    du musst den Style vom label ändern dann geht es :D

    [autoit]

    #include <GUIConstantsEx.au3>
    Local $sand = "&"
    Local $sVariable = "A"&$sand& "B + C"

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

    MsgBox(0, "Was steht drin?", $sVariable)

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

    Example($sVariable)

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

    Func Example($sVariable)

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

    ; Create a GUI with various controls.
    Local $hGUI = GUICreate($sVariable)
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

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

    GUICtrlCreateLabel($sVariable, 100, 100 , "" , "" ,0x0B , "" )

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

    ; Display the GUI.GUISetState
    GUISetState(@SW_SHOW, $hGUI)

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

    ; Loop until the user exits.
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $idOK
    ExitLoop
    EndSwitch
    WEnd

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

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
    EndFunc ;==>Example

    [/autoit]


    achja in Zeile 18 von deinen Example skript hast du das GUISETSTATE vergessen :D
    aber so sollte es klappen :D

    Es gibt 102
    Arten von Menschen:
    Jene, die Binärcode verstehen
    und jene, die es nicht tun.

  • Das liegt daran, dass das & Zeichen bei Controls dazu dienen, den ALT Modus zu aktivieren. Das heißt in folgendem Beispiel wenn ALT + der jeweilige Nachfolgende Buchstabe nach dem & Zeichen gedrückt wird, löst das dementsprechende Control aus:

    Spoiler anzeigen
    [autoit]

    GUICreate("")
    $Button1 = GUICtrlCreateButton("&Test1", 10, 10, 100)
    $Button2 = GUICtrlCreateButton("T&est2", 10, 40, 100)
    $Button3 = GUICtrlCreateButton("Te&st3", 10, 70, 100)
    GUISetState()

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

    While 1
    Switch GUIGetMsg()
    Case -3
    Exit
    Case $Button1
    MsgBox(0, "Button1", "Button1 pressed via ALT + t.")
    Case $Button2
    MsgBox(0, "Button2", "Button2 pressed via ALT + e.")
    Case $Button3
    MsgBox(0, "Button3", "Button3 pressed via ALT + s.")
    EndSwitch
    WEnd

    [/autoit]
  • Ich habe zu dem Quellcode mal kurz eine Frage. das "h" bei $hGUI - steht das für "handle" oder für "hex"? Denn die Handles sind soweit ich weiß in Hex angegeben..

    Spoiler anzeigen

    Überraschung!


    MfG Donkey