InfoLabel - Einfaches Label aufgepeppt

  • Hier ein kleines Beispiel wie man sein Programm ein bischen aufpeppen kann.
    Vllt kann es jemand mal brauchen.

    Spoiler anzeigen
    [autoit]

    GUICreate("Test InfoLabel", 400, 220)

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

    Global $nInfoLbl = _InfoLabel_Create(110, 10, 180, 40, "This is an example text" & @CRLF & "with two lines. Click me!", "InfoLabel title", 0x44FF)
    Global $nInfoLbl2 = _InfoLabel_Create(110, 60, 180, 40, "This is an example text" & @CRLF & "with two lines" & @CRLF & "no three! And no title.")
    _InfoLabel_Create(10, 110, 380, 100, "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying 'runtimes' required!", "Introduction")

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

    GUISetState()

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

    Global $iMsg
    While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case -3
    ExitLoop
    Case $nInfoLbl
    _InfoLabel_SetText($nInfoLbl, "New Text" & @CRLF & "Thank you ;)")
    Case $nInfoLbl2
    _InfoLabel_SetTitle($nInfoLbl2, "New Title")
    EndSwitch
    WEnd

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

    Func _InfoLabel_Create($x, $y, $w, $h, $sText, $sTitle = "", $iTitleCol = 0xFF0000)
    GUICtrlCreateLabel("", $x + 2, $y + $h, $w, 2, 0x05) ;$SS_GRAYRECT, acts as shadow
    GUICtrlCreateLabel("", $x + $w, $y + 2, 2, $h, 0x05) ;$SS_GRAYRECT, acts as shadow
    Local $nCtrl = GUICtrlCreateLabel($sTitle, $x, $y, $w, $h, BitOR(0x00800000, 0x1), 0x8) ;WS_BORDER or $SS_CENTER
    GUICtrlSetColor(-1, $iTitleCol)
    GUICtrlSetBkColor(-1, 0xFFFFDF)

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

    Local $sStart
    If $sTitle <> "" Then $sStart = @CRLF
    GUICtrlCreateLabel($sStart & $sText, $x, $y, $w, $h, 0x1) ;$SS_CENTER
    GUICtrlSetBkColor(-1, -2) ;$GUI_BKCOLOR_TRANSPARENT
    Return $nCtrl
    EndFunc ;==>_InfoLabel_Create

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

    Func _InfoLabel_SetTitle($nCtrl, $sTitle)
    If GUICtrlRead($nCtrl) = "" Then GUICtrlSetData($nCtrl + 1, @CRLF & GUICtrlRead($nCtrl + 1))
    If $sTitle = "" Then GUICtrlSetData($nCtrl + 1, StringStripWS(GUICtrlRead($nCtrl + 1), 1))
    GUICtrlSetData($nCtrl, $sTitle)
    EndFunc ;==>_InfoLabel_SetTitle

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

    Func _InfoLabel_SetText($nCtrl, $sText)
    If GUICtrlRead($nCtrl) = "" Then
    GUICtrlSetData($nCtrl + 1, $sText)
    Else
    GUICtrlSetData($nCtrl + 1, @CRLF & $sText)
    EndIf
    EndFunc ;==>_InfoLabel_SetText

    [/autoit]

    Viel Spaß