GDIPlus Digitaluhr

  • Mein erstes neues Programm seit langem... Es ist nichts großes, aber ganz nett. Ich hoffe es gefällt euch :).
    Der Quellcode für die kleine Digitaluhr befindet sich im Anhang. Extradateien werden nicht benötigt, bis auf die Schriftart...
    Auf Windows XP scheint das ganze nicht korrekt zu funktionieren, aber das sollte nicht allzu tragisch sein. ;)

    Code
    [autoit]

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

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

    Opt("GUIOnEventMode", 1)

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

    $iWidth = 115
    $iHeight = 50
    $iX_Pos = @DesktopWidth / 2 - 56
    $iY_Pos = @DesktopHeight / 2 - 25

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

    #region -DLLStruct
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, "X", 0)
    DllStructSetData($tPoint, "Y", 0)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth)
    DllStructSetData($tSize, "Y", $iHeight)
    $tDest = DllStructCreate($tagPOINT)
    $pDest = DllStructGetPtr($tDest)
    DllStructSetData($tDest, "X", $iX_Pos)
    DllStructSetData($tDest, "Y", $iY_Pos)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)
    #endregion -DLLStruct

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

    $hWnd = GUICreate("Clock", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
    GUISetState()

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

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

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

    _GDIPlus_Startup()

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

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

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

    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Sony Sketch EF")
    $hFont = _GDIPlus_FontCreate($hFamily, 20)

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

    $tLayout_HourX10 = _GDIPlus_RectFCreate(0)
    $tLayout_HourX1 = _GDIPlus_RectFCreate(16)
    $tLayout_Colon1 = _GDIPlus_RectFCreate(34, $iHeight / 2 - 15)
    $tLayout_MinX10 = _GDIPlus_RectFCreate(40)
    $tLayout_MinX1 = _GDIPlus_RectFCreate(56)
    $tLayout_Colon2 = _GDIPlus_RectFCreate(74, $iHeight / 2 - 15)
    $tLayout_SecX10 = _GDIPlus_RectFCreate(80)
    $tLayout_SecX1 = _GDIPlus_RectFCreate(96)

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

    $hBrush_Numbers = _GetBrush()

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

    OnAutoItExitRegister("_Shutdown")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hWnd)

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

    While Sleep(30)
    _GDIPlus_GraphicsClear($hGraphics, 0)

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

    $iSecX1 = Mod(@SEC, 10)
    $iSecX10 = Floor(@SEC / 10)
    $iMinX1 = Mod(@MIN, 10)
    $iMinX10 = Floor(@MIN / 10)
    $iHourX1 = Mod(@HOUR, 10)
    $iHourX10 = Floor(@HOUR / 10)

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

    $iY_SecX1 = @MSEC / 1000 * $iHeight / 3 - 9
    If $iSecX1 = 0 Then
    $iY_SecX10 = $iY_SecX1
    Else
    $iY_SecX10 = $iHeight / 3 - 9
    EndIf
    If @SEC = 0 Then
    $iY_MinX1 = $iY_SecX1
    Else
    $iY_MinX1 = $iHeight / 3 - 9
    EndIf
    If $iMinX1 = 0 And @SEC = 0 Then
    $iY_MinX10 = $iY_SecX1
    Else
    $iY_MinX10 = $iHeight / 3 - 9
    EndIf
    If @MIN = 0 And @SEC = 0 Then
    $iY_HourX1 = $iY_SecX1
    Else
    $iY_HourX1 = $iHeight / 3 - 9
    EndIf
    If $iHourX1 = 0 And @MIN = 0 And @SEC = 0 Then
    $iY_HourX10 = $iY_SecX1
    Else
    $iY_HourX10 = $iHeight / 3 - 9
    EndIf

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

    #region -Hours
    DllStructSetData($tLayout_HourX1, "Y", $iHeight - $iY_HourX1 - 15)
    If ($iHourX1 = 3 And $iHourX10 = 2) Or $iHourX1 = 9 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX1 + 1, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_HourX1, "Y", $iHeight / 3 * 2 - $iY_HourX1 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX1, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_HourX1, "Y", $iHeight / 3 - $iY_HourX1 - 15)
    If $iHourX1 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 9, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX1 - 1, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_HourX10, "Y", $iHeight - $iY_HourX10 - 15)
    If $iHourX10 = 2 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX10 + 1, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_HourX10, "Y", $iHeight / 3 * 2 - $iY_HourX10 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX10, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_HourX10, "Y", $iHeight / 3 - $iY_HourX10 - 15)
    If $iHourX10 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 2, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX10 - 1, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    EndIf
    #endregion -Hours

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

    #region -Minutes
    DllStructSetData($tLayout_MinX1, "Y", $iHeight - $iY_MinX1 - 15)
    If $iMinX1 = 9 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX1 + 1, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_MinX1, "Y", $iHeight / 3 * 2 - $iY_MinX1 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX1, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_MinX1, "Y", $iHeight / 3 - $iY_MinX1 - 15)
    If $iMinX1 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 9, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX1 - 1, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_MinX10, "Y", $iHeight - $iY_MinX10 - 15)
    If $iMinX10 = 5 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX10 + 1, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_MinX10, "Y", $iHeight / 3 * 2 - $iY_MinX10 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX10, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_MinX10, "Y", $iHeight / 3 - $iY_MinX10 - 15)
    If $iMinX10 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 5, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX10 - 1, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    EndIf
    #endregion -Minutes

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

    #region -Seconds
    DllStructSetData($tLayout_SecX1, "Y", $iHeight - $iY_SecX1 - 15)
    If $iSecX1 = 9 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX1 + 1, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_SecX1, "Y", $iHeight / 3 * 2 - $iY_SecX1 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX1, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_SecX1, "Y", $iHeight / 3 - $iY_SecX1 - 15)
    If $iSecX1 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 9, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX1 - 1, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_SecX10, "Y", $iHeight - $iY_SecX10 - 15)
    If $iSecX10 = 5 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX10 + 1, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_SecX10, "Y", $iHeight / 3 * 2 - $iY_SecX10 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX10, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_SecX10, "Y", $iHeight / 3 - $iY_SecX10 - 15)
    If $iSecX10 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 5, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX10 - 1, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    EndIf
    #endregion -Seconds

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

    _GDIPlus_GraphicsDrawStringEx($hGraphics, ":", $hFont, $tLayout_Colon1, $hFormat, $hBrush_Numbers)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, ":", $hFont, $tLayout_Colon2, $hFormat, $hBrush_Numbers)

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

    _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, $pDest, $pSize, $hDC_Bitmap, $pSource, 0, $pBlend, $ULW_ALPHA)
    WEnd

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

    Func _GetBrush()
    $hBitmapTmp = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hGraphicsTmp = _GDIPlus_ImageGetGraphicsContext($hBitmapTmp)
    $hBrushTmp1 = _GDIPlus_LineBrushCreate(0, $iHeight / 2 - 17, 0, $iHeight / 2, 0, 0xD0A0A0A0)
    $hBrushTmp2 = _GDIPlus_LineBrushCreate(0, $iHeight / 2, 0, $iHeight / 2 + 17, 0xD0A0A0A0, 0)

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

    _GDIPlus_GraphicsFillRect($hGraphicsTmp, 0, $iHeight / 2 - 17, $iWidth, 17, $hBrushTmp1)
    _GDIPlus_GraphicsFillRect($hGraphicsTmp, 0, $iHeight / 2, $iWidth, 17, $hBrushTmp2)
    $hReturn = _GDIPlus_TextureCreate($hBitmapTmp, 4)

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

    _GDIPlus_GraphicsDispose($hGraphicsTmp)
    _GDIPlus_BitmapDispose($hBitmapTmp)
    _GDIPlus_BrushDispose($hBrushTmp1)
    _GDIPlus_BrushDispose($hBrushTmp2)

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

    Return $hReturn
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

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

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

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BrushDispose($hBrush_Numbers)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_Shutdown()
    EndFunc ;==>_Shutdown

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

    #region GDIP Functions
    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] [autoit][/autoit] [autoit]

    Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult

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

    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)

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

    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)

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

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

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

    Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hImage, "int", $iWrapMode, "int*", 0)

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

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[3]
    EndFunc ;==>_GDIPlus_TextureCreate
    #endregion GDIP Functions

    [/autoit]
  • Also ick klick da druff, näh? un denn....passiert nischt, näh? also dit geht uff, un denn geht dit wieder zu wah.
    Aber ick se nüscht.
    Dit is ja an sich nit schlimm, aber ick globb nit dat dit so sein sollte :)

    Weß ick nich, evntl isset ja och Layer 8. Ick hän Win7 32bit

  • Unter Win 7 x64 passiert auch nichts. Das Script läuft zwar als Prozess aber es wird nichts angezeigt.

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Habs nun auch zum Laufen bekommen,war doch Layer8.
    Aber eben halt auch nur zum Laufen, mehr nicht.
    Der Prozess steht, die Font ist auf "Sylfaen" geändert, dennoch weit und breit keine Uhr.

  • Hast du das Font installiert? Ich stell das mal als Anhang rein...

    Ok jetzt gehts, sieht gut aus :).

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Fehler gefunden:

    Unter XP wird das Fenster nicht automatisch sichtbar, wenn man ein Layered Window erzeugt. Daher:
    WinSetTrans($hWnd, '', 255)

    UpdateLayeredwindow klappt auch nicht wie gewünscht.
    ersetzen durch:
    _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
    _WinAPI_BitBlt($hDC_Bitmap, 0, 0, $iWidth, $iHeight, 0, 0, 0, $BLACKNESS)

    Läuft !

    Spoiler anzeigen
    [autoit]

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

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

    Opt("GUIOnEventMode", 1)

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

    $iWidth = 115
    $iHeight = 50
    $iX_Pos = @DesktopWidth / 2 - 56
    $iY_Pos = @DesktopHeight / 2 - 25

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

    #region -DLLStruct
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, "X", 0)
    DllStructSetData($tPoint, "Y", 0)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth)
    DllStructSetData($tSize, "Y", $iHeight)
    $tDest = DllStructCreate($tagPOINT)
    $pDest = DllStructGetPtr($tDest)
    DllStructSetData($tDest, "X", $iX_Pos)
    DllStructSetData($tDest, "Y", $iY_Pos)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)
    #endregion -DLLStruct

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

    $hWnd = GUICreate("Clock", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
    WinSetTrans($hWnd, '', 255)
    GUISetState(@SW_SHOW, $hWnd)

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

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

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

    _GDIPlus_Startup()

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

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

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

    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 20)

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

    $tLayout_HourX10 = _GDIPlus_RectFCreate(0)
    $tLayout_HourX1 = _GDIPlus_RectFCreate(16)
    $tLayout_Colon1 = _GDIPlus_RectFCreate(34, $iHeight / 2 - 15)
    $tLayout_MinX10 = _GDIPlus_RectFCreate(40)
    $tLayout_MinX1 = _GDIPlus_RectFCreate(56)
    $tLayout_Colon2 = _GDIPlus_RectFCreate(74, $iHeight / 2 - 15)
    $tLayout_SecX10 = _GDIPlus_RectFCreate(80)
    $tLayout_SecX1 = _GDIPlus_RectFCreate(96)

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

    $hBrush_Numbers = _GetBrush()

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

    OnAutoItExitRegister("_Shutdown")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hWnd)

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

    While Sleep(30)
    _GDIPlus_GraphicsClear($hGraphics, 0)

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

    $iSecX1 = Mod(@SEC, 10)
    $iSecX10 = Floor(@SEC / 10)
    $iMinX1 = Mod(@MIN, 10)
    $iMinX10 = Floor(@MIN / 10)
    $iHourX1 = Mod(@HOUR, 10)
    $iHourX10 = Floor(@HOUR / 10)

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

    $iY_SecX1 = @MSEC / 1000 * $iHeight / 3 - 9
    If $iSecX1 = 0 Then
    $iY_SecX10 = $iY_SecX1
    Else
    $iY_SecX10 = $iHeight / 3 - 9
    EndIf
    If @SEC = 0 Then
    $iY_MinX1 = $iY_SecX1
    Else
    $iY_MinX1 = $iHeight / 3 - 9
    EndIf
    If $iMinX1 = 0 And @SEC = 0 Then
    $iY_MinX10 = $iY_SecX1
    Else
    $iY_MinX10 = $iHeight / 3 - 9
    EndIf
    If @MIN = 0 And @SEC = 0 Then
    $iY_HourX1 = $iY_SecX1
    Else
    $iY_HourX1 = $iHeight / 3 - 9
    EndIf
    If $iHourX1 = 0 And @MIN = 0 And @SEC = 0 Then
    $iY_HourX10 = $iY_SecX1
    Else
    $iY_HourX10 = $iHeight / 3 - 9
    EndIf

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

    #region -Hours
    DllStructSetData($tLayout_HourX1, "Y", $iHeight - $iY_HourX1 - 15)
    If ($iHourX1 = 3 And $iHourX10 = 2) Or $iHourX1 = 9 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX1 + 1, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_HourX1, "Y", $iHeight / 3 * 2 - $iY_HourX1 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX1, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_HourX1, "Y", $iHeight / 3 - $iY_HourX1 - 15)
    If $iHourX1 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 9, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX1 - 1, $hFont, $tLayout_HourX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_HourX10, "Y", $iHeight - $iY_HourX10 - 15)
    If $iHourX10 = 2 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX10 + 1, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_HourX10, "Y", $iHeight / 3 * 2 - $iY_HourX10 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX10, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_HourX10, "Y", $iHeight / 3 - $iY_HourX10 - 15)
    If $iHourX10 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 2, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iHourX10 - 1, $hFont, $tLayout_HourX10, $hFormat, $hBrush_Numbers)
    EndIf
    #endregion -Hours

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

    #region -Minutes
    DllStructSetData($tLayout_MinX1, "Y", $iHeight - $iY_MinX1 - 15)
    If $iMinX1 = 9 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX1 + 1, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_MinX1, "Y", $iHeight / 3 * 2 - $iY_MinX1 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX1, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_MinX1, "Y", $iHeight / 3 - $iY_MinX1 - 15)
    If $iMinX1 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 9, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX1 - 1, $hFont, $tLayout_MinX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_MinX10, "Y", $iHeight - $iY_MinX10 - 15)
    If $iMinX10 = 5 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX10 + 1, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_MinX10, "Y", $iHeight / 3 * 2 - $iY_MinX10 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX10, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_MinX10, "Y", $iHeight / 3 - $iY_MinX10 - 15)
    If $iMinX10 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 5, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iMinX10 - 1, $hFont, $tLayout_MinX10, $hFormat, $hBrush_Numbers)
    EndIf
    #endregion -Minutes

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

    #region -Seconds
    DllStructSetData($tLayout_SecX1, "Y", $iHeight - $iY_SecX1 - 15)
    If $iSecX1 = 9 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX1 + 1, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_SecX1, "Y", $iHeight / 3 * 2 - $iY_SecX1 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX1, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_SecX1, "Y", $iHeight / 3 - $iY_SecX1 - 15)
    If $iSecX1 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 9, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX1 - 1, $hFont, $tLayout_SecX1, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_SecX10, "Y", $iHeight - $iY_SecX10 - 15)
    If $iSecX10 = 5 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 0, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX10 + 1, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    EndIf

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

    DllStructSetData($tLayout_SecX10, "Y", $iHeight / 3 * 2 - $iY_SecX10 - 15)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX10, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)

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

    DllStructSetData($tLayout_SecX10, "Y", $iHeight / 3 - $iY_SecX10 - 15)
    If $iSecX10 = 0 Then
    _GDIPlus_GraphicsDrawStringEx($hGraphics, 5, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    Else
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $iSecX10 - 1, $hFont, $tLayout_SecX10, $hFormat, $hBrush_Numbers)
    EndIf
    #endregion -Seconds

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

    _GDIPlus_GraphicsDrawStringEx($hGraphics, ":", $hFont, $tLayout_Colon1, $hFormat, $hBrush_Numbers)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, ":", $hFont, $tLayout_Colon2, $hFormat, $hBrush_Numbers)

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

    ;~ _WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, $pDest, $pSize, $hDC_Bitmap, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
    _WinAPI_BitBlt($hDC_Bitmap, 0, 0, $iWidth, $iHeight, 0, 0, 0, $BLACKNESS)
    WEnd

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

    Func _GetBrush()
    $hBitmapTmp = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hGraphicsTmp = _GDIPlus_ImageGetGraphicsContext($hBitmapTmp)
    $hBrushTmp1 = _GDIPlus_LineBrushCreate(0, $iHeight / 2 - 17, 0, $iHeight / 2, 0, 0xD0A0A0A0)
    $hBrushTmp2 = _GDIPlus_LineBrushCreate(0, $iHeight / 2, 0, $iHeight / 2 + 17, 0xD0A0A0A0, 0)

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

    _GDIPlus_GraphicsFillRect($hGraphicsTmp, 0, $iHeight / 2 - 17, $iWidth, 17, $hBrushTmp1)
    _GDIPlus_GraphicsFillRect($hGraphicsTmp, 0, $iHeight / 2, $iWidth, 17, $hBrushTmp2)
    $hReturn = _GDIPlus_TextureCreate($hBitmapTmp, 4)

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

    _GDIPlus_GraphicsDispose($hGraphicsTmp)
    _GDIPlus_BitmapDispose($hBitmapTmp)
    _GDIPlus_BrushDispose($hBrushTmp1)
    _GDIPlus_BrushDispose($hBrushTmp2)

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

    Return $hReturn
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

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

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

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BrushDispose($hBrush_Numbers)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_Shutdown()
    EndFunc ;==>_Shutdown

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

    #region GDIP Functions
    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] [autoit][/autoit] [autoit]

    Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult

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

    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)

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

    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)

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

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

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

    Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hImage, "int", $iWrapMode, "int*", 0)

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

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[3]
    EndFunc ;==>_GDIPlus_TextureCreate
    #endregion GDIP Functions

    [/autoit]


    Kann jemand das mal auf Win7 Testen, ob das genau so aussieht, wie die originalvariante ?
    (Bei mir hat die Uhr einen schwarzen Rand, die Animation ist aber schön :) )

    lg
    M

  • OMG 300 Zeilen Code für ne Uhr 8|

    Finde deinen Post eine absolute Frechheit. Du bist selbst nichtmal annähernd in der Lage so etwas zu machen.

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • @Marsi: auf meinem Win7 x64 + Aero wird die Uhr in einem schwarzem Rechteck angezeigt, d.h. keine Transparenz.

    name22: nette Idee!

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Danke für das Feedback :). Ich werde in den nächsten Tagen mal versuchen den Quellcode ein wenig aufzuräumen und "universaler" zu gestalten (d.h. dass die Einstellungen wie Breite/Höhe und auch Schriftart und Farbe verändert werden können ohne den kompletten Code umzukrempeln. Ich habe die Koordinaten nämlich momentan mithilfe von Konstanten zurechtgebogen wodurch die Uhr allerdings auf das eine Font beschränkt wird.)

  • name22: du kannst den Font auch direkt laden und benutzen, ohne ihn vorher installieren zu müssen!

    Finde gerade kein Beispiel...

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯