GUICtrlSetFont klappt nicht

  • Hallo,

    ich habe folgendes Problem:

    Ich ermittele zuerst ein Control mit der + Taste.
    Das geht.
    Aber wie kann ich dann diesem Control eine andere Größe zuteilen?

    Mein Code:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    HotKeySet("{NUMPADADD}", "plus")
    #Region ### START Koda GUI section ### Form=
    Global $Form1 = GUICreate("Form1", 361, 118, 256, 409)
    Global $Input1 = GUICtrlCreateInput("Input1", 27, 19, 121, 21)
    Global $bt1 = GUICtrlCreateButton("1", 27, 67, 75, 25, $WS_GROUP)
    Global $bt2 = GUICtrlCreateButton("2", 115, 67, 75, 25, $WS_GROUP)
    Global $bt3 = GUICtrlCreateButton("3", 203, 67, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $FontSize = 20
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

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

    Func plus()
    Local $control
    $control = ControlGetFocus($Form1)

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

    Switch ControlGetFocus($Form1)
    Case $control
    MsgBox(0, "", $control)
    GUICtrlSetFont($control, $FontSize + 10)

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

    EndSwitch
    EndFunc ;==>plus

    [/autoit]

    Grüße
    ;) Ilse

    Einmal editiert, zuletzt von Ilse (20. April 2012 um 20:31)

    • Offizieller Beitrag

    Probier mal das:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <WinAPI.au3>
    HotKeySet("{NUMPADADD}", "plus")
    #region ### START Koda GUI section ### Form=
    Global $Form1 = GUICreate("Form1", 361, 118, 256, 409)
    Global $Input1 = GUICtrlCreateInput("Input1", 27, 19, 121, 21)
    Global $bt1 = GUICtrlCreateButton("1", 27, 67, 75, 25, $WS_GROUP)
    Global $bt2 = GUICtrlCreateButton("2", 115, 67, 75, 25, $WS_GROUP)
    Global $bt3 = GUICtrlCreateButton("3", 203, 67, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    $FontSize = 20
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

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

    Func plus()
    Local $control = ControlGetFocus($Form1)
    Local $hHandle = ControlGetHandle($Form1, "", $control); Handle des selektierten Controls holen
    Local $ICtrlId = _WinAPI_GetDlgCtrlID($hHandle); CtrlId aus dem Handle erstellen
    MsgBox(0, "", $control)
    GUICtrlSetFont($ICtrlId, $FontSize + 10)
    EndFunc ;==>plus

    [/autoit]