Transparents und scharfe Schrift

  • Hallo,
    ich bin momentan an einer Uhr dran die für ein Kumpel ist und soweit funktioniert sie auch.
    Mein Problem an der ganzen Geschichte ist aber, das die Schrift von der Uhr unscharf ist und das ich die Schrift selbst nicht Transparent machen kann :(

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <WinApi.au3>

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

    $hGui = GUICreate("Clock", 460, 150, Default, (@DesktopHeight / 2) + ((@DesktopHeight / 2 / 2)), $WS_POPUP, BitOR($WS_EX_TRANSPARENT, $WS_EX_LAYERED))
    GUISetBkColor(0x010203)
    _WinAPI_SetLayeredWindowAttributes($hGui, 0x010203)
    $oLabelClock = GUICtrlCreateLabel(@HOUR & ":" & @MIN, 0, 0, 500, 500)
    GUICtrlSetFont(-1, 100, 800, 0, "Bookman Old Style", 2)
    GUICtrlSetColor(-1, 0x000000)
    $oLabelClockSeonds = GUICtrlCreateLabel(@SEC, 400, 85, 70, 40)
    GUICtrlSetFont(-1, 30, 800, 0, "Bookman Old Style", 2)
    GUICtrlSetColor(-1, 0x000000)
    GUISetState(@SW_SHOW)

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

    $nTimerDefault = TimerInit()
    $nTimerSeconds = TimerInit()

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

    While 1
    Switch GUIGetMsg()
    Case $oLabelClock

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

    Case -3
    Exit
    EndSwitch

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

    If ((TimerDiff($nTimerDefault) >= 10000) And (GUICtrlRead($oLabelClock) <> @HOUR & ":" & @MIN)) Then
    GUICtrlSetData($oLabelClock, @HOUR & ":" & @MIN)
    $nTimerDefault = TimerInit()
    EndIf
    If ((TimerDiff($nTimerSeconds) >= 1000) And (GUICtrlRead($oLabelClockSeonds) <> @SEC)) Then
    GUICtrlSetData($oLabelClockSeonds, @SEC)
    $nTimerSeconds = TimerInit()
    EndIf
    WEnd

    [/autoit]

    Kann mir da einer helfen bitte?

  • Das liegt an der Kantenglättung der Schrift. Die Funktion _WinAPI_SetLayeredWindowAttributes legt nur eine einzige Farbe als transparent fest. Da bei der Kantenglättung aber teiltransparente Pixel eingefügt werden die die selbe Farbe haben wie das Objekt, aber den Hintergrund leicht durchscheinen lassen, werden diese Pixel ignoriert weil der resultierende Farbton nicht der Hintergrundfarbe entspricht. Der Farbanteil des Hintergrunds ist aber immer noch in diesen Pixeln zu sehen was deinen Schriftzug optisch niederqualitativ aussehen lässt.
    Eine Möglichkeit dieses Problem zu lösen bietet GDI+ in Kombination mit Mehrschichtigen GUIs. Ich habe schon vor einiger Zeit mal ein Beispiel für sowas geschrieben: https://autoit.de/index.php?page…1221#post211221
    Wenn du das so umsetzt, sollte die Schriftqualität wesentlich besser sein und Teiltransparenz (z.B. 40% Sichtbarkeit) ist auch möglich.

  • Das lässt sich wahrscheinlich längst nicht mehr als Beispiel klassifizieren, aber ich hatte gerade solche Lust ein GDI+ basiertes Script zu schreiben :P...

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>

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

    ; - Author: name22 (http://www.autoit.de)

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

    Opt("GUIOnEventMode", 1)

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

    $iWidth = 460
    $iHeight = 150

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

    $sFontName = "Bookman Old Style"
    $iARGB_Font = 0xA0000000

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

    $nIntervall = 200

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

    $hWnd = GUICreate("Clock", $iWidth, $iHeight, Default, Default, $WS_POPUP, $WS_EX_LAYERED)
    GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, Default, $GUI_WS_EX_PARENTDRAG)
    GUISetState()

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

    $hDC_Window = _WinAPI_GetDC($hWnd)
    $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Window)
    $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
    _WinAPI_SelectObject($hDC_Buffer, $hBitmap)

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, 3)

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

    $hStringFormat = _GDIPlus_StringFormatCreate()
    $hFontFamily = _GDIPlus_FontFamilyCreate($sFontName)
    $hFont = _GDIPlus_FontCreate($hFontFamily, 100, 1, 3)
    $hBrush = _GDIPlus_BrushCreateSolid($iARGB_Font)

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

    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth)
    DllStructSetData($tSize, "Y", $iHeight)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)

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

    _UpdateTime()
    AdlibRegister("_UpdateTime", $nIntervall)

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

    GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_RESTORE, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    OnAutoItExitRegister("_Shutdown")

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

    While Sleep(10000)
    WEnd

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

    Func _UpdateTime()
    Local Static $sCurTime = "", $sNewTime = @HOUR & ":" & @MIN, $tLayout = _GDIPlus_RectFCreate()

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

    $sNewTime = @HOUR & ":" & @MIN
    If $sNewTime = $sCurTime Then Return 0

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

    $sCurTime = $sNewTime
    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphics, $sCurTime, $hFont, $tLayout, $hStringFormat)
    $iStringWidth = DllStructGetData($aMeasure[0], "Width")
    $iStringHeight = DllStructGetData($aMeasure[0], "Height")
    DllStructSetData($aMeasure[0], "X", $iWidth / 2 - $iStringWidth / 2)
    DllStructSetData($aMeasure[0], "Y", $iHeight / 2 - $iStringHeight / 2)

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

    _GDIPlus_GraphicsClear($hGraphics, 0)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sNewTime, $hFont, $aMeasure[0], $hStringFormat, $hBrush)
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _WM_PAINT()
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

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

    Func _Shutdown()
    _WinAPI_ReleaseDC($hWnd, $hDC_Window)
    _WinAPI_DeleteDC($hDC_Buffer)
    _WinAPI_DeleteObject($hBitmap)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFontFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()
    EndFunc

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

    Func _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $iTextRenderingHint)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "hwnd", $hGraphics, "int", $iTextRenderingHint)

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

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_GraphicsSetTextRenderingHint

    [/autoit]


    Du solltest allerdings beachten, dass derjenige der nachher das Programm benutzt auch das von dir spezifizierte Font installiert hat. Egal bei welcher Methode, ansonsten passiert nix ;).

  • Falls du die Lösung willst, hier:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>

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

    ; - Author: name22 (http://www.autoit.de)

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

    Opt("GUIOnEventMode", 1)

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

    $iWidth = 600
    $iHeight = 150

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

    $sFontName = "Arial"
    $iARGB_Font = 0xA0000000

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

    $nIntervall = 200

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

    $hWnd = GUICreate("Clock", $iWidth, $iHeight, Default, Default, $WS_POPUP, $WS_EX_LAYERED)
    GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, Default, $GUI_WS_EX_PARENTDRAG)
    GUISetState()

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

    $hDC_Window = _WinAPI_GetDC($hWnd)
    $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Window)
    $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
    _WinAPI_SelectObject($hDC_Buffer, $hBitmap)

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, 3)

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

    $hStringFormat = _GDIPlus_StringFormatCreate()
    $hFontFamily = _GDIPlus_FontFamilyCreate($sFontName)
    $hFont = _GDIPlus_FontCreate($hFontFamily, 100, 1, 3)
    $hBrush = _GDIPlus_BrushCreateSolid($iARGB_Font)

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

    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth)
    DllStructSetData($tSize, "Y", $iHeight)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)

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

    _UpdateTime()
    AdlibRegister("_UpdateTime", $nIntervall)

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

    GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_RESTORE, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    OnAutoItExitRegister("_Shutdown")

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

    While Sleep(10000)
    WEnd

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

    Func _UpdateTime()
    Local Static $sCurTime = "", $sNewTime = @HOUR & ":" & @MIN & ":" & @SEC, $tLayout = _GDIPlus_RectFCreate()

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

    $sNewTime = @HOUR & ":" & @MIN & ":" & @SEC
    If $sNewTime = $sCurTime Then Return 0

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

    $sCurTime = $sNewTime
    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphics, $sCurTime, $hFont, $tLayout, $hStringFormat)
    $iStringWidth = DllStructGetData($aMeasure[0], "Width")
    $iStringHeight = DllStructGetData($aMeasure[0], "Height")
    DllStructSetData($aMeasure[0], "X", $iWidth / 2 - $iStringWidth / 2)
    DllStructSetData($aMeasure[0], "Y", $iHeight / 2 - $iStringHeight / 2)

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

    _GDIPlus_GraphicsClear($hGraphics, 0)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sNewTime, $hFont, $aMeasure[0], $hStringFormat, $hBrush)
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _WM_PAINT()
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

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

    Func _Shutdown()
    _WinAPI_ReleaseDC($hWnd, $hDC_Window)
    _WinAPI_DeleteDC($hDC_Buffer)
    _WinAPI_DeleteObject($hBitmap)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFontFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()
    EndFunc

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

    Func _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $iTextRenderingHint)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "hwnd", $hGraphics, "int", $iTextRenderingHint)

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

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_GraphicsSetTextRenderingHint

    [/autoit]


    Du musst lediglich den String anpassen der gezeichnet wird, indem du ihn um ein Makro ergänzt und die Fensterbreite erhöhen damit das ganze da rein passt ;). Also wirklich kein Grund zu verzweifeln ^^.

  • Eigentlich wollte ich es nicht so haben, das ist doch unschön :D
    Ich möchte die Sekundenanzeige unten rechts als kleine Schrift haben.
    Leider bin ich gerade am verzweifeln wie ich eine kleinere Schrift an den String haue. Ich habe es hinbekommen eine große und kleine Schrift anzeigen zu lassen aber die Sekunden überschreiben die Stunden und Minuten und ich sehe die Sekunden nun doppelt, bin aber noch am testen :D

    Edit:
    Okay, soweit binn ich schon, wie verschiebe ich jetzt die Sekunden nach rechts?

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <Array.au3>

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

    ; - Author: name22 (http://www.autoit.de)

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

    Opt("GUIOnEventMode", 1)

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

    $iWidth = 460
    $iHeight = 150

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

    $sFontName = "Bookman Old Style"
    $iARGB_Font = 0xA0000000

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

    $nIntervall = 200

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

    $hWnd = GUICreate("Clock", $iWidth+60, $iHeight, Default, (@DesktopHeight / 2) + ((@DesktopHeight / 2 / 2)), $WS_POPUP, BitOR ($WS_EX_TRANSPARENT,$WS_EX_LAYERED))
    GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, Default, $GUI_WS_EX_PARENTDRAG)
    GUISetState()

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

    $hDC_Window = _WinAPI_GetDC($hWnd)
    $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Window)
    $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
    _WinAPI_SelectObject($hDC_Buffer, $hBitmap)

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
    $hGraphics2 = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics2, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, 3)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphics2, 3)

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

    $hStringFormat = _GDIPlus_StringFormatCreate()
    $hFontFamily = _GDIPlus_FontFamilyCreate($sFontName)
    $hFont = _GDIPlus_FontCreate($hFontFamily, 100, 1, 3)
    $hFont2 = _GDIPlus_FontCreate($hFontFamily, 30, 1, 3)
    $hBrush = _GDIPlus_BrushCreateSolid($iARGB_Font)

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

    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth)
    DllStructSetData($tSize, "Y", $iHeight)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)

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

    _UpdateTime()
    AdlibRegister("_UpdateTime", $nIntervall)

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

    GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_RESTORE, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    OnAutoItExitRegister("_Shutdown")

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

    While Sleep(10000)
    WEnd

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

    Func _UpdateTime()
    Local Static $sCurTime = "", $tLayout = _GDIPlus_RectFCreate()

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

    $sNewTime = @SEC
    If $sNewTime = $sCurTime Then Return 0

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

    $sCurTime = $sNewTime
    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphics, @HOUR & ":" & @MIN, $hFont, $tLayout, $hStringFormat)

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

    _GDIPlus_GraphicsClear($hGraphics, 0)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, @HOUR & ":" & @MIN, $hFont, $aMeasure[0], $hStringFormat, $hBrush)
    _GDIPlus_GraphicsDrawStringEx($hGraphics2, @SEC, $hFont2, $aMeasure[0], $hStringFormat, $hBrush)
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _WM_PAINT()
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

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

    Func _Shutdown()
    _WinAPI_ReleaseDC($hWnd, $hDC_Window)
    _WinAPI_DeleteDC($hDC_Buffer)
    _WinAPI_DeleteObject($hBitmap)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFontFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()
    EndFunc

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

    Func _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $iTextRenderingHint)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "hwnd", $hGraphics, "int", $iTextRenderingHint)

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

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_GraphicsSetTextRenderingHint

    [/autoit]

    Einmal editiert, zuletzt von Freaky (22. August 2012 um 02:10)

  • Dein Script hat ein paar kleine Fehler... Du brauchst doch nicht 2 Grafiken, das macht doch gar keinen Sinn...
    Ich hab es mal entsprechend geändert, hast du dir das so vorgestellt?

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>

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

    ; - Author: name22 (http://www.autoit.de)

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

    Opt("GUIOnEventMode", 1)

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

    $iWidth = 600
    $iHeight = 150

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

    $sFontName = "Arial"
    $iARGB_Font = 0xA0000000

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

    $nIntervall = 200

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

    $hWnd = GUICreate("Clock", $iWidth, $iHeight, Default, Default, $WS_POPUP, $WS_EX_LAYERED)
    GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, Default, $GUI_WS_EX_PARENTDRAG)
    GUISetState()

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

    $hDC_Window = _WinAPI_GetDC($hWnd)
    $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Window)
    $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
    _WinAPI_SelectObject($hDC_Buffer, $hBitmap)

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, 3)

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

    $hStringFormat = _GDIPlus_StringFormatCreate()
    $hFontFamily = _GDIPlus_FontFamilyCreate($sFontName)
    $hFont_Time = _GDIPlus_FontCreate($hFontFamily, 100, 1, 3)
    $hFont_Sec = _GDIPlus_FontCreate($hFontFamily, 50, 1, 3)
    $hBrush = _GDIPlus_BrushCreateSolid($iARGB_Font)

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

    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth)
    DllStructSetData($tSize, "Y", $iHeight)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)

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

    _UpdateTime()
    AdlibRegister("_UpdateTime", $nIntervall)

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

    GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_RESTORE, "_WM_PAINT")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    OnAutoItExitRegister("_Shutdown")

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

    While Sleep(10000)
    WEnd

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

    Func _UpdateTime()
    Local Static $sCurTime = "", $sCurSec = -1, $sNewTime, $sNewSec, $tLayout = _GDIPlus_RectFCreate()

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

    $sNewTime = @HOUR & ":" & @MIN
    $sNewSec = ":" & @SEC
    If $sNewTime = $sCurTime And $sNewSec = $sCurSec Then Return 0

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

    $sCurTime = $sNewTime
    $sCurSec = $sNewSec
    $aMeasure_Time = _GDIPlus_GraphicsMeasureString($hGraphics, $sCurTime, $hFont_Time, $tLayout, $hStringFormat)
    $iStringWidth_Time = DllStructGetData($aMeasure_Time[0], "Width")
    $iStringHeight_Time = DllStructGetData($aMeasure_Time[0], "Height")
    $aMeasure_Sec = _GDIPlus_GraphicsMeasureString($hGraphics, $sCurSec, $hFont_Sec, $tLayout, $hStringFormat)
    $iStringWidth_Sec = DllStructGetData($aMeasure_Sec[0], "Width")
    $iStringHeight_Sec = DllStructGetData($aMeasure_Sec[0], "Height")
    DllStructSetData($aMeasure_Time[0], "X", $iWidth / 2 - ($iStringWidth_Time + $iStringWidth_Sec + 30) / 2)
    DllStructSetData($aMeasure_Time[0], "Y", $iHeight / 2 - $iStringHeight_Time / 2)
    DllStructSetData($aMeasure_Sec[0], "X", DllStructGetData($aMeasure_Time[0], "X") + $iStringWidth_Time - 30)
    DllStructSetData($aMeasure_Sec[0], "Y", DllStructGetData($aMeasure_Time[0], "Y") + $iStringHeight_Time - $iStringHeight_Sec - 25)

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

    _GDIPlus_GraphicsClear($hGraphics, 0)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sCurTime, $hFont_Time, $aMeasure_Time[0], $hStringFormat, $hBrush)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sCurSec, $hFont_Sec, $aMeasure_Sec[0], $hStringFormat, $hBrush)
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _WM_PAINT()
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

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

    Func _Shutdown()
    _WinAPI_ReleaseDC($hWnd, $hDC_Window)
    _WinAPI_DeleteDC($hDC_Buffer)
    _WinAPI_DeleteObject($hBitmap)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFontFamily)
    _GDIPlus_FontDispose($hFont_Time)
    _GDIPlus_FontDispose($hFont_Sec)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()
    EndFunc

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

    Func _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $iTextRenderingHint)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "hwnd", $hGraphics, "int", $iTextRenderingHint)

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

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_GraphicsSetTextRenderingHint

    [/autoit]