ToolTip() Formatieren

  • Hi leute, ja schon wieder ich :S

    Vlt haben es manche gelesen im chat hab aber keine antwort erhalten also frag ich einfach nochmal :D Wisst ihr, wie man einen ToolTip formatieren kann? also zb dass der text in rot und fett geschrieben wird?

    MfG Err 8o rKid

    • Offizieller Beitrag

    Mußt du dir dann selbst schreiben: Gui mit Style WS_POPUP, dann kannst du formatieren, wie du lustig bist.

    Ich hatte da mal was:

    Spoiler anzeigen
    [autoit]

    #include-once
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <FontConstants.au3>

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

    _SplashOn('Hello World', 200, 100,-1,-1,-1,-1,-1,0)

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

    ;==================================================================================================
    ; Function Name: _SplashOn($Item, $width=-1, $height=-1, $left=-1, $top=-1, $timeout=-1, $txtCol=-1, $bkCol=-1, $trans=1, $size=-1, $font=-1)
    ; Description:: Show an SplashImage (gif,jpg,bmp) or an SplashText
    ; Parameter(s): $Item - Path picture file or SplashText; Autodetection if file or text
    ; part optional $width - text: width; picture: - by default(-1) use original size of picture
    ; part optional $height - text: height; picture: - by default(-1) use original size of picture
    ; optional $left - left margin (default=-1 horizontal centered)
    ; optional $top - upper margin (default=-1 vertikal centered)
    ; optional $timeout- time how long to show picture/text (default=-1, 3 seconds)
    ; optional $txtCol - SplashText: text color RGB (default=-1, red)
    ; optional $bkCol - SplashText: back color RGB (default=-1, black)
    ; optional $trans - SplashText: background transparency yes/now (default=1, yes)
    ; optional $size - SplashText: font size (default=-1, 30) ; 14 conforms approximately 12 at TimesNewRoman
    ; optional $font - SplashText: font name (default=-1, Arial)
    ; Return: Succes - 1
    ; Failure - 0 set @error: 1= given file doesn't exist; 2= no size given for textarea
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;==================================================================================================
    Func _SplashOn($Item, $width=-1, $height=-1, $left=-1, $top=-1, $timeout=-1, $txtCol=-1, $bkCol=-1, $trans=1, $size=-1, $font=-1) ; picture path or text
    If $timeout < 0 Then $timeout = 3000
    If $txtCol < 0 Then $txtCol = 0xFF0000
    If $bkCol < 0 Then $bkCol = 0x000000
    If $trans < 0 Then $trans = 0
    If $size < 0 Then $size = 30
    If $font = -1 Then $font = 'Arial'
    If StringRegExp(StringLeft($Item, 3), '[a-zA-Z]:\\') Then ; picture
    If Not FileExists($Item) Then Return SetError(1,0,0)
    If ($width = -1) Or ($height = -1) Then
    Local $objShell = ObjCreate("Shell.Application")
    Local $objFSO = ObjCreate("Scripting.FileSystemObject")
    Local $objFile = $objFSO.GetFile($Item)
    Local $FileName = $objFSO.GetFileName($objFile)
    Local $objFolder = $objShell.Namespace($objFSO.GetParentFolderName($objFile))
    For $strFileName In $objFolder.Items
    If $objFolder.GetDetailsOf($strFileName, 0) <> $FileName Then ContinueLoop
    $width = StringRegExpReplace($objFolder.GetDetailsOf($strFileName, 27), '(\d+).*', '$1')
    $height = StringRegExpReplace($objFolder.GetDetailsOf($strFileName, 28), '(\d+).*', '$1')
    Next
    EndIf
    Local $gui = GUICreate("", $width, $height, $left, $top, $WS_POPUP, $WS_EX_TOPMOST)
    Local $ctrl = GUICtrlCreatePic($Item, 0, 0, $width, $height)
    GUISetState(@SW_SHOW)
    Local $pos = WinGetPos($gui), $combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    Local $ctrl_pos = ControlGetPos($gui, "", $ctrl)
    Local $ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0], $ctrl_pos[1], $ctrl_pos[0] + $ctrl_pos[2], $ctrl_pos[1] + $ctrl_pos[3])
    _WinAPI_CombineRgn($combined_rgn, $combined_rgn, $ctrl_rgn, $RGN_OR)
    _WinAPI_DeleteObject($ctrl_rgn)
    _WinAPI_SetWindowRgn($gui, $combined_rgn)
    Sleep($timeout)
    GUIDelete($gui)
    Else ; text
    If ($width = -1) Or ($height = -1) Then Return SetError(2,0,0)
    If $left = -1 Then $left = Int((@DesktopWidth/2) - ($width/2))
    If $top = -1 Then $top = Int((@DesktopHeight/2) - ($height/2))
    Local $tRECT, $hFont, $hOldFont, $hDC
    $tRECT = DllStructCreate($tagRect)
    DllStructSetData($tRECT, "Left", $left)
    DllStructSetData($tRECT, "Top", $top)
    DllStructSetData($tRECT, "Right", $left + $width)
    DllStructSetData($tRECT, "Bottom", $top + $height)
    $hDC = _WinAPI_GetDC(0)
    $hFont = _WinAPI_CreateFont($size, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
    $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, $font)
    $hOldFont = _WinAPI_SelectObject($hDC, $hFont)
    Local $sH = Hex($txtCol,6)
    $txtCol = '0x' & StringRight($sH, 2) & StringMid($sH,3,2) & StringLeft($sH, 2)
    $sH = Hex($BkCol,6)
    $bkCol = '0x' & StringRight($sH, 2) & StringMid($sH,3,2) & StringLeft($sH, 2)
    _WinAPI_SetTextColor($hDC, $txtCol)
    _WinAPI_SetBkColor($hDC, $bkCol)
    If $trans Then _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    Local $timer = TimerInit()
    Do
    _WinAPI_DrawText($hDC, $Item, $tRECT, $DT_CENTER)
    Sleep(20)
    Until TimerDiff($timer) > $timeout
    _WinAPI_SelectObject($hDC, $hOldFont)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_InvalidateRect(0, 0)
    $tRECT = 0
    EndIf
    Return 1
    EndFunc ;==>_SplashOn

    [/autoit]
    • Offizieller Beitrag

    funkey: Das läßt sich aber nicht formatieren. ;)

    Habe meine Version mal noch aktualisiert und Textmeter integriert. Dann braucht man keine Größe mehr übergeben. Als Position wird standardmäßig die Mausposition (bzw. rechts unterhalb davon) gewählt.
    Hier zu finden: SplashImage / -Text, randlos, formatierbar