GDI+ Button mit Hovereffekt

  • Hallo Community!

    Ich hab vor, eigene Buttons mit Hilfe von GDI+ zu zeichnen. Ist auch kein Problem.
    Wie soll ich am besten überprüfen, wenn der Mauszeiger auf das Bild ist, um ein anderes Bild anzuzeigen.
    Positionen auslesen usw. oder gibts da ein GetMsg *blabla*?

    Mir gehts auch natürlich um die Geschwindigkeit usw.

    Danke und Mfg. Tince

  • Das musste ich bei meinem Spiel auch machen. Einmal Hover und bei drücken. Wenn das Sript läuft drücke mal die Pause-Taste, dann zeigt er das menü an, was komplett in GDI+ gemacht ist (_MenuShow).

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <GDIPlus.au3>
    #include <GDIP.au3>
    #include <GUIConstants.au3>
    #include <Misc.au3>
    #Include <WinAPI.au3>
    #include <WindowsConstants.au3>
    #include <StructureConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $iMenuReturn
    Global $aEnableForGo[4] ; [links, oben, rechts, unten]
    Global $aTimer[6], $Hold[4]
    Global $iCountPoints = 0
    Global $iGuiWidth = 600
    Global $iGuiHeight = 600
    Global $iX = 0
    Global $iY = 0
    Global $iAngleStart = 20
    Global $iAngleEnd = 320
    Global $piewidth = 0
    Global $pieheight = 320
    Global $aSquarePos[4]
    Global $aBG[12][12] = [[1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1], _
    [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0], _
    [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], _
    [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], _
    [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1], _
    [1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0], _
    [1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1], _
    [1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1], _
    [0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1], _
    [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], _
    [1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1], _
    [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]]

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

    ;~ Global $aBG[12][12] = [[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], _
    ;~ [0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], _
    ;~ [0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
    ;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

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

    Global $aPoints = $aBG

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

    HotKeySet("{PAUSE}", "_MenuShow")

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

    $hDLL = DllOpen("user32.dll")

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

    $hGui = GUICreate("PacMan made by m-obi", $iGuiWidth, $iGuiHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState()

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

    _GDIPlus_Startup ()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGuiWidth, $iGuiHeight, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    $hBrush_Pac = _GDIPlus_BrushCreateSolid(0xFFFFFF00)
    $Brush1 = _GDIPlus_BrushCreateSolid(0xFFEEEEEE)
    $Brush2 = _GDIPlus_BrushCreateSolid(0xFF000000)
    $Brush3 = _GDIPlus_BrushCreateSolid(0xFF636363)
    $Brush_Red = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $Brush_Green = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    _SquarePos()
    _BG()
    _DrawPoints()

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

    AdlibRegister("_SquarePos", 50)
    AdlibRegister("_AniPacMan", 400)

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

    While 1
    Switch $iMenuReturn
    Case 0
    Opt("MouseCoordMode", 1)
    Opt("GUIOnEventMode", 1)
    HotKeySet("{PAUSE}", "_MenuShow")
    _Time("start")
    Case 1
    _Exit()
    EndSwitch

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

    _CheckPoints()

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

    If TimerDiff($aTimer[1]) > 200 Then _Draw(1)

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

    ;ToolTip($aSquarePos[0] & @CRLF & $aSquarePos[1] & @CRLF & $aSquarePos[2] & @CRLF & $aSquarePos[3])

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

    If $aSquarePos[0] > 0.9 Then $aEnableForGo[0] = $aBG[Int($aSquarePos[1])][Int($aSquarePos[0]) - 1]
    If $aSquarePos[1] > 0.9 Then $aEnableForGo[1] = $aBG[Int($aSquarePos[1]) - 1][Int($aSquarePos[0])]
    If $aSquarePos[0] < 11 Then $aEnableForGo[2] = $aBG[Int($aSquarePos[1])][Int($aSquarePos[0]) + 1]
    If $aSquarePos[1] < 11 Then $aEnableForGo[3] = $aBG[Int($aSquarePos[1]) + 1][Int($aSquarePos[0])]

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

    _SquarePos()

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

    $aEnableForGo[0] = _Iif($aSquarePos[0] = 0.5 Or (Not $aEnableForGo[0] And StringRight($aSquarePos[0], 1) = 5), 0, 1)
    $aEnableForGo[1] = _Iif($aSquarePos[1] = 0.5 Or (Not $aEnableForGo[1] And StringRight($aSquarePos[1], 1) = 5), 0, 1)
    $aEnableForGo[2] = _Iif($aSquarePos[0] = 11.5 Or (Not $aEnableForGo[2] And StringRight($aSquarePos[0], 1) = 5), 0, 1)
    $aEnableForGo[3] = _Iif($aSquarePos[1] = 11.5 Or (Not $aEnableForGo[3] And StringRight($aSquarePos[1], 1) = 5), 0, 1)

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

    If Not _IsPressed("25", $hDLL) Then $Hold[0] = 0
    If Not _IsPressed("26", $hDLL) Then $Hold[1] = 0
    If Not _IsPressed("27", $hDLL) Then $Hold[2] = 0
    If Not _IsPressed("28", $hDLL) Then $Hold[3] = 0

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

    If WinActive($hGui) And StringRight($aSquarePos[0], 1) = 5 Then
    Select
    Case _IsPressed("26", $hDLL) And $aEnableForGo[1] ;oben
    _Time("start")
    If Not $Hold[1] Then $aTimer[3] = TimerInit()
    $Hold[1] = 1
    $iAngleStart = 290
    $iY -= 10
    _Draw()
    While _IsPressed("26", $hDLL) And TimerDiff($aTimer[3]) < 300
    Sleep(10)
    WEnd
    Case _IsPressed("28", $hDLL) And $aEnableForGo[3] ;unten
    _Time("start")
    If Not $Hold[3] Then $aTimer[5] = TimerInit()
    $Hold[3] = 1
    $iAngleStart = 110
    $iY += 10
    _Draw()
    While _IsPressed("28", $hDLL) And TimerDiff($aTimer[5]) < 300
    Sleep(10)
    WEnd
    EndSelect
    EndIf

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

    _SquarePos()

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

    If WinActive($hGui) And StringRight($aSquarePos[1], 1) = 5 Then
    Select
    Case _IsPressed("25", $hDLL) And $aEnableForGo[0] ;links
    _Time("start")
    If Not $Hold[0] Then $aTimer[2] = TimerInit()
    $Hold[0] = 1
    $iAngleStart = 200
    $iX -= 10
    _Draw()
    While _IsPressed("25", $hDLL) And TimerDiff($aTimer[2]) < 300
    Sleep(10)
    WEnd
    Case _IsPressed("27", $hDLL) And $aEnableForGo[2] ;rechts
    _Time("start")
    If Not $Hold[2] Then $aTimer[4] = TimerInit()
    $Hold[2] = 1
    $iAngleStart = 20
    $iX += 10
    _Draw()
    While _IsPressed("27", $hDLL) And TimerDiff($aTimer[4]) < 300
    Sleep(10)
    WEnd
    EndSelect
    EndIf
    WEnd

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

    Func _Draw($iTyp = 0)
    AdlibUnRegister("_SquarePos")
    _GDIPlus_GraphicsSetSmoothingMode_New($hBuffer, 3)
    _GDIPlus_GraphicsFillRect($hBuffer, Int($aSquarePos[0]) * 50, Int($aSquarePos[1]) * 50, 50, 50, $Brush1)
    _GDIPlus_GraphicsFillRect($hBuffer, Int($aSquarePos[2]) * 50, Int($aSquarePos[3]) * 50, 50, 50, $Brush1)
    If StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) = 5 And $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] Then
    $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] = 0
    $iCountPoints -= 1
    EndIf
    _GDIPlus_GraphicsSetSmoothingMode_New($hBuffer, 4)
    If $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] Then _GDIPlus_GraphicsFillEllipse($hBuffer, Int($aSquarePos[0]) * 50 + 15, Int($aSquarePos[1]) * 50 + 15, 20, 20, $Brush3)
    If $aPoints[Int($aSquarePos[3])][Int($aSquarePos[2])] Then _GDIPlus_GraphicsFillEllipse($hBuffer, Int($aSquarePos[2]) * 50 + 15, Int($aSquarePos[3]) * 50 + 15, 20, 20, $Brush3)
    AdlibRegister("_SquarePos", 50)
    While 1
    Switch $iTyp
    Case 0
    $iTyp = _Iif(TimerDiff($aTimer[1]) > 200, 1, 2)
    Case 1
    _GDIPlus_GraphicsFillPie($hBuffer, $iX + 2, $iY + 2, 46, 46, $iAngleStart, $iAngleEnd, $hBrush_Pac)
    ExitLoop
    Case 2
    _GDIPlus_GraphicsFillPie($hBuffer, $iX + 2, $iY + 2, 46, 46, $iAngleStart - 15, $iAngleEnd + 30, $hBrush_Pac)
    ExitLoop
    EndSwitch
    WEnd
    _GDIPlus_GraphicsSetSmoothingMode_New($hBuffer, 3)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGuiWidth, $iGuiHeight)
    EndFunc

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

    Func _DrawPoints()
    _GDIPlus_GraphicsSetSmoothingMode_New($hBuffer, 4)
    If StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) = 5 Then $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] = 0
    For $y = 0 To UBound($aPoints) - 1
    For $x = 0 To UBound($aPoints, 2) - 1
    If $aPoints[$y][$x] Then
    _GDIPlus_GraphicsFillEllipse($hBuffer, $x * 50 + 15, $y * 50 + 15, 20, 20, $Brush3)
    $iCountPoints += 1
    EndIf
    Next
    Next
    _GDIPlus_GraphicsSetSmoothingMode_New($hBuffer, 3)
    EndFunc

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

    Func _AniPacMan()
    _Draw(2)
    $aTimer[1] = TimerInit()
    EndFunc

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

    Func _BG()
    _GDIPlus_GraphicsFillRect($hBuffer, 0, 0, 600, 600, $Brush2)
    For $y = 0 To UBound($aBG) - 1
    For $x = 0 To UBound($aBG, 2) - 1
    If $aBG[$y][$x] Then _GDIPlus_GraphicsFillRect($hBuffer, $x * 50, $y * 50, 50, 50, $Brush1)
    Next
    Next
    EndFunc

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

    Func _SquarePos()
    $aSquarePos[0] = ($iX / 50) + 0.5
    $aSquarePos[1] = ($iY / 50) + 0.5
    Select
    Case StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) = 5
    $aSquarePos[2] = $aSquarePos[0]
    $aSquarePos[3] = $aSquarePos[1]
    Case StringRight($aSquarePos[0], 1) < 5 And StringRight($aSquarePos[1], 1) = 5
    $aSquarePos[2] = $aSquarePos[0] - 1
    $aSquarePos[3] = $aSquarePos[1]
    Case StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) < 5
    $aSquarePos[2] = $aSquarePos[0]
    $aSquarePos[3] = $aSquarePos[1] - 1
    Case StringRight($aSquarePos[0], 1) > 5 And StringRight($aSquarePos[1], 1) = 5
    $aSquarePos[2] = $aSquarePos[0] + 1
    $aSquarePos[3] = $aSquarePos[1]
    Case StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) > 5
    $aSquarePos[2] = $aSquarePos[0]
    $aSquarePos[3] = $aSquarePos[1] + 1
    EndSelect
    EndFunc

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

    Func _CheckPoints()
    If $iCountPoints = 0 Then
    MsgBox(0, "Test", "Test")
    EndIf
    EndFunc

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

    Func _Time($sCommand)
    Local Static $iTime
    Switch $sCommand
    Case "start"
    If $aTimer[0] = "" Then $aTimer[0] = TimerInit()
    Case "stop"
    If $aTimer[0] <> "" Then
    $iTime += TimerDiff($aTimer[0])
    $aTimer[0] = ""
    Return $iTime
    EndIf
    EndSwitch
    EndFunc

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

    Func _MenuShow()
    _Time("stop")

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

    Local $iWidth = 200
    Local $iHeight = 300
    Local $iRadius = 30
    Local $iOffset = 3
    Local $aButton[3]
    Local $aHover[3] = [0, 0, 0]
    Local $aPress[3] = [0, 0, 0]
    Local $aPressed[3] = [0, 0, 0]
    Local $aPressBefore[3] = [0, 0, 0]

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

    HotKeySet("{PAUSE}")
    GUISetState(@SW_DISABLE, $hGui)
    Opt("GUIOnEventMode", 0)

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

    $hGuiMenu = GUICreate("Menü", $iWidth + 6, $iHeight + 6, -1, -1, 0, $WS_EX_LAYERED)
    ;~ $hGuiMenu1 = GUICreate("", 80, 25, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST, $hGuiMenu)
    ;~ GUISetBkColor(0xF0F0F0)
    ;~ _WinAPI_SetLayeredWindowAttributes($hGuiMenu1, 0xF0F0F0)
    ;~ $hContinue = GUICtrlCreateButton("Weiter", 0, 0, 80, 25)
    ;~ WinSetTrans($hGuiMenu1, "", 180)

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

    $hGraphicMenu = _GDIPlus_GraphicsCreateFromHWND($hGuiMenu)
    $hBitmapMenu = _GDIPlus_BitmapCreateFromGraphics($iWidth + 6, $iHeight + 6, $hGraphicMenu)
    $hBufferMenu = _GDIPlus_ImageGetGraphicsContext($hBitmapMenu)
    $hScreenDC = _WinAPI_GetDC($hGuiMenu)
    $hHBitmapMenu = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmapMenu)
    $hDC = _WinAPI_CreateCompatibleDC($hScreenDC)
    _WinAPI_SelectObject($hDC, $hHBitmapMenu)
    ; _WinAPI_UpdateLayeredWindow parameters
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $iWidth + 6)
    DllStructSetData($tSize, "Y", $iHeight + 6)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", 0xFF)
    DllStructSetData($tBlend, "Format", 1)
    $tPoint = DllStructCreate($tagPOINT)
    $pPoint = DllStructGetPtr($tPoint)
    DllStructSetData($tPoint, "X", 0)
    DllStructSetData($tPoint, "Y", 0)

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

    $hBrush_BG = _GDIPlus_BrushCreateSolid(0xAAFFA500)
    $hPen_BG = _GDIPlus_PenCreate(0xFF000000, 3)
    _GDIPlus_GraphicsFillRect($hBufferMenu, $iOffset, $iRadius + $iOffset, $iRadius, $iHeight - $iRadius * 2, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hBufferMenu, $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 180, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hBufferMenu, $iRadius + $iOffset, $iOffset, $iWidth - $iRadius * 2, $iRadius, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 270, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hBufferMenu, $iWidth - $iRadius + $iOffset, $iRadius + $iOffset, $iRadius, $iHeight - $iRadius * 2, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 0, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hBufferMenu, $iRadius + $iOffset, $iHeight - $iRadius + $iOffset, $iWidth - $iRadius * 2, $iRadius, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hBufferMenu, $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 90, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hBufferMenu, $iRadius + $iOffset, $iRadius + $iOffset, $iWidth - $iRadius * 2, $iHeight - $iRadius * 2, $hBrush_BG)
    _GDIPlus_GraphicsSetSmoothingMode_New($hBufferMenu, 4)
    _GDIPlus_GraphicsDrawLine($hBufferMenu, $iOffset, $iHeight - $iRadius + $iOffset, $iOffset, $iRadius + $iOffset, $hPen_BG)
    _GDIPlus_GraphicsDrawArc($hBufferMenu, $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 180, 90, $hPen_BG)
    _GDIPlus_GraphicsDrawLine($hBufferMenu, $iRadius + $iOffset, $iOffset, $iWidth - $iRadius + $iOffset, $iOffset, $hPen_BG)
    _GDIPlus_GraphicsDrawArc($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 270, 90, $hPen_BG)
    _GDIPlus_GraphicsDrawLine($hBufferMenu, $iWidth + $iOffset, $iRadius + $iOffset, $iWidth + $iOffset, $iHeight - $iRadius + $iOffset, $hPen_BG)
    _GDIPlus_GraphicsDrawArc($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 0, 90, $hPen_BG)
    _GDIPlus_GraphicsDrawLine($hBufferMenu, $iRadius + $iOffset, $iHeight + $iOffset, $iWidth - $iRadius + $iOffset, $iHeight + $iOffset, $hPen_BG)
    _GDIPlus_GraphicsDrawArc($hBufferMenu, $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 90, 90, $hPen_BG)
    _GDIPlus_GraphicsSetSmoothingMode_New($hBufferMenu, 3)

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

    $aButton[0] = _DrawButton($hBufferMenu, $hBitmapMenu, "Weiter", -1, 30, 120, 30, "Arial", 12)
    $aButton[1] = _DrawButton($hBufferMenu, $hBitmapMenu, "Hilfe", -1, 80, 120, 30, "Arial", 12)
    $aButton[2] = _DrawButton($hBufferMenu, $hBitmapMenu, "Beenden", -1, 150, 120, 30, "Arial", 12)

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

    $hHBitmapMenu = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmapMenu)
    _WinAPI_SelectObject($hDC, $hHBitmapMenu)
    _WinAPI_UpdateLayeredWindow($hGuiMenu, $hScreenDC, 0, $pSize, $hDC, $pSource, 0, $pBlend, 2)

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

    ;~ GUISetState(@SW_SHOW, $hGuiMenu1)
    GUISetState(@SW_SHOW, $hGuiMenu)

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

    Opt("MouseCoordMode", 0)

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

    While 1
    For $i = 0 To UBound($aButton) - 1
    $sTextButton = DllStructGetData($aButton[$i], "Text")
    $iLeftButton = DllStructGetData($aButton[$i], "Left")
    $iTopButton = DllStructGetData($aButton[$i], "Top")
    $iWidthButton = DllStructGetData($aButton[$i], "Width")
    $iHeightButton = DllStructGetData($aButton[$i], "Height")
    $iRadiusButton = DllStructGetData($aButton[$i], "Radius")
    $aPos = MouseGetPos()
    ;ToolTip($aPos[0] & "|" & $aPos[1])
    If ($aPos[0] - $iLeftButton - $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 + ($aPos[1] - $iTopButton - $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 <= 1 _
    Or ($aPos[0] - $iLeftButton - $iWidthButton + $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 + ($aPos[1] - $iTopButton - $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 <= 1 _
    Or ($aPos[0] - $iLeftButton - $iWidthButton + $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 + ($aPos[1] - $iTopButton - $iHeightButton + $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 <= 1 _
    Or ($aPos[0] - $iLeftButton - $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 + ($aPos[1] - $iTopButton - $iHeightButton + $iRadiusButton) ^ 2 / $iRadiusButton ^ 2 <= 1 _
    Or ($aPos[0] > $iLeftButton And $aPos[0] < ($iLeftButton + $iWidthButton) And $aPos[1] > ($iTopButton + $iRadiusButton) And $aPos[1] < ($iTopButton + $iHeightButton - $iRadiusButton)) _
    Or ($aPos[0] > ($iLeftButton + $iRadiusButton) And $aPos[0] < ($iLeftButton + $iWidthButton - $iRadiusButton) And $aPos[1] > $iTopButton And $aPos[1] < ($iTopButton + $iHeightButton)) Then

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

    If _IsPressed("01") And Not $aPress[$i] And Not $aPressBefore[$i] Then
    _DrawButton($hBufferMenu, $hBitmapMenu, $sTextButton, $iLeftButton, $iTopButton, $iWidthButton, $iHeightButton, "Arial", 12, 3)
    $aPress[$i] = 1
    $aPressed[$i] = 1
    EndIf
    If Not _IsPressed("01") Then
    $aPressed[$i] = 0
    $aPressBefore[$i] = 0
    If $aPress[$i] Then
    $aHover[$i] = 0
    $aPress[$i] = 0
    Switch $sTextButton
    Case "Weiter", "Beenden"
    _WinAPI_DeleteObject($hHBitmapMenu)
    _GDIPlus_PenDispose($hPen_BG)
    _GDIPlus_BrushDispose($hBrush_BG)
    _WinAPI_DeleteDC($hDC)
    _WinAPI_ReleaseDC($hGuiMenu, $hScreenDC)
    _GDIPlus_GraphicsDispose($hBufferMenu)
    _GDIPlus_BitmapDispose($hBitmapMenu)
    $tSize = ""
    $tSource = ""
    $tBlend = ""
    $tPoint = ""
    Switch $sTextButton
    Case "Weiter"
    ConsoleWrite(@CRLF & "-- Weiter --")
    $iMenuReturn = 0
    Case "Beenden"
    ConsoleWrite(@CRLF & "-- Beenden --")
    $iMenuReturn = 1
    EndSwitch
    GUISetState(@SW_ENABLE, $hGui)
    GUIDelete($hGuiMenu)
    ;~ GUIDelete($hGuiMenu1)
    Return
    Case "Hilfe"
    ConsoleWrite(@CRLF & "-- Hilfe --")
    EndSwitch
    EndIf
    EndIf
    If Not $aHover[$i] And Not $aPress[$i] Then
    _DrawButton($hBufferMenu, $hBitmapMenu, $sTextButton, $iLeftButton, $iTopButton, $iWidthButton, $iHeightButton, "Arial", 12, 2)
    $aHover[$i] = 1
    EndIf
    Else
    $aPressBefore[$i] = 0
    If _IsPressed("01") Then
    If Not $aPressed[$i] Then $aPressBefore[$i] = 1
    Else
    $aPressed[$i] = 0
    EndIf
    If $aHover[$i] Or $aPress[$i] Then
    _DrawButton($hBufferMenu, $hBitmapMenu, $sTextButton, $iLeftButton, $iTopButton, $iWidthButton, $iHeightButton, "Arial", 12)
    $aPress[$i] = 0
    $aHover[$i] = 0
    EndIf
    EndIf
    $hHBitmapMenu = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmapMenu)
    _WinAPI_SelectObject($hDC, $hHBitmapMenu)
    _WinAPI_UpdateLayeredWindow($hGuiMenu, $hScreenDC, 0, $pSize, $hDC, $pSource, 0, $pBlend, 2)
    Next
    Sleep(50)
    ;~ Switch GUIGetMsg()
    ;~ Case $hContinue
    ;~ _WinAPI_DeleteObject($hHBitmapMenu)
    ;~ _GDIPlus_PenDispose($hPen_BG)
    ;~ _GDIPlus_PenDispose($hPen_BG)
    ;~ _GDIPlus_BrushDispose($hBrush_BG)
    ;~ _WinAPI_DeleteDC($hDC)
    ;~ _WinAPI_ReleaseDC($hGuiMenu, $hScreenDC)
    ;~ _GDIPlus_GraphicsDispose($hBufferMenu)
    ;~ _GDIPlus_BitmapDispose($hBitmapMenu)
    ;~ $tSize = ""
    ;~ $tSource = ""
    ;~ $tBlend = ""
    ;~ $tPoint = ""
    ;~ GUISetState(@SW_ENABLE, $hGui)
    ;~ GUIDelete($hGuiMenu)
    ;~ GUIDelete($hGuiMenu1)
    ;~ Opt("MouseCoordMode", 1)
    ;~ Opt("GUIOnEventMode", 1)
    ;~ HotKeySet("{PAUSE}", "_MenuShow")
    ;~ _Time("start")
    ;~ Return
    ;~ EndSwitch
    WEnd
    EndFunc

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

    Func _DrawButton($hGraphic, $hBitmap, $sText, $iLeft, $iTop, $iWidth, $iHeight, $sFont = "Arial", $iFontSize = 10, $iState = 1)
    Local $iRadius = 10
    Local $iWidthBitmap = _GDIPlus_ImageGetWidth($hBitmap)
    Switch $iState
    Case 1 ; normal
    ConsoleWrite(@CRLF & $sText & " nicht hover")
    Local $hBrush_BG = _GDIPlus_BrushCreateSolid(0xC8FFA500)
    Case 2 ; hover
    ConsoleWrite(@CRLF & $sText & " hover")
    Local $hBrush_BG = _GDIPlus_BrushCreateSolid(0xC800FF00)
    Case 3 ; pressed
    ConsoleWrite(@CRLF & $sText & " gedrückt")
    Local $hBrush_BG = _GDIPlus_BrushCreateSolid(0xC8FF0000)
    EndSwitch
    Local $hBrush_Text = _GDIPlus_BrushCreateSolid(0xFF000000)
    Local $hPen = _GDIPlus_PenCreate(0xFF000000, 2)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0)
    Local $tLayout = _GDIPlus_RectFCreate($iLeft, $iTop, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont, $tLayout, $hFormat)
    Local $iWidthText = Int(DllStructGetData($aInfo[0], "Width"))
    Local $iHeightText = Int(DllStructGetData($aInfo[0], "Height"))

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

    If $iLeft = -1 Then $iLeft = ($iWidthBitmap - $iWidth) / 2

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

    $tLayout = _GDIPlus_RectFCreate($iLeft + (($iWidth - $iWidthText) / 2), $iTop + (($iHeight - $iHeightText) / 2), 0, 0)
    $hBrush_Test = _GDIPlus_LineBrushCreate(0, 0, 0, 8, 0xFF000000, 0xC8FFA500)
    _GDIPlus_GraphicsFillRect($hGraphic, $iLeft, $iRadius + $iTop, $iRadius, $iHeight - $iRadius * 2, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hGraphic, $iLeft, $iTop, $iRadius * 2, $iRadius * 2, 180, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hGraphic, $iRadius + $iLeft, $iTop, $iWidth - $iRadius * 2, $iRadius, $hBrush_Test)
    _GDIPlus_GraphicsFillPie($hGraphic, $iWidth - $iRadius * 2 + $iLeft, $iTop, $iRadius * 2, $iRadius * 2, 270, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hGraphic, $iWidth - $iRadius + $iLeft, $iRadius + $iTop, $iRadius, $iHeight - $iRadius * 2, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hGraphic, $iWidth - $iRadius * 2 + $iLeft, $iHeight - $iRadius * 2 + $iTop, $iRadius * 2, $iRadius * 2, 0, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hGraphic, $iRadius + $iLeft, $iHeight - $iRadius + $iTop, $iWidth - $iRadius * 2, $iRadius, $hBrush_BG)
    _GDIPlus_GraphicsFillPie($hGraphic, $iLeft, $iHeight - $iRadius * 2 + $iTop, $iRadius * 2, $iRadius * 2, 90, 90, $hBrush_BG)
    _GDIPlus_GraphicsFillRect($hGraphic, $iRadius + $iLeft, $iRadius + $iTop, $iWidth - $iRadius * 2, $iHeight - $iRadius * 2, $hBrush_BG)
    _GDIPlus_GraphicsSetSmoothingMode_New($hGraphic, 4)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iLeft, $iHeight - $iRadius + $iTop, $iLeft, $iRadius + $iTop, $hPen)
    _GDIPlus_GraphicsDrawArc($hGraphic, $iLeft, $iTop, $iRadius * 2, $iRadius * 2, 180, 90, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iRadius + $iLeft, $iTop, $iWidth - $iRadius + $iLeft, $iTop, $hPen)
    _GDIPlus_GraphicsDrawArc($hGraphic, $iWidth - $iRadius * 2 + $iLeft, $iTop, $iRadius * 2, $iRadius * 2, 270, 90, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iWidth + $iLeft, $iRadius + $iTop, $iWidth + $iLeft, $iHeight - $iRadius + $iTop, $hPen)
    _GDIPlus_GraphicsDrawArc($hGraphic, $iWidth - $iRadius * 2 + $iLeft, $iHeight - $iRadius * 2 + $iTop, $iRadius * 2, $iRadius * 2, 0, 90, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iRadius + $iLeft, $iHeight + $iTop, $iWidth - $iRadius + $iLeft, $iHeight + $iTop, $hPen)
    _GDIPlus_GraphicsDrawArc($hGraphic, $iLeft, $iHeight - $iRadius * 2 + $iTop, $iRadius * 2, $iRadius * 2, 90, 90, $hPen)
    _GDIPlus_GraphicsSetSmoothingMode_New($hGraphic, 3)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush_Text)

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

    $hStruct = DllStructCreate("char Text[10]; int Left; int Top; int Width; int Height; int Radius")
    DllStructSetData($hStruct, "Text", $sText)
    DllStructSetData($hStruct, "Left", $iLeft)
    DllStructSetData($hStruct, "Top", $iTop)
    DllStructSetData($hStruct, "Width", $iWidth)
    DllStructSetData($hStruct, "Height", $iHeight)
    DllStructSetData($hStruct, "Radius", $iRadius)

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

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_BrushDispose($hBrush_BG)

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

    Return $hStruct
    EndFunc

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

    Func _Exit()
    _GDIPlus_BrushDispose($hBrush_Pac)
    _GDIPlus_BrushDispose($Brush1)
    _GDIPlus_BrushDispose($Brush2)
    _GDIPlus_BrushDispose($Brush3)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    DllClose($hDLL)
    Exit
    EndFunc

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

    Func _GDIPlus_GraphicsGetSmoothingMode_New($hGraphic)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipGetSmoothingMode", "handle", $hGraphic, "int*", 0)
    If @error Then Return SetError(@error, @extended, -1)
    Return $aResult[2]
    EndFunc ;==>_GDIPlus_GraphicsGetSmoothingMode_New

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

    Func _GDIPlus_GraphicsSetSmoothingMode_New($hGraphic, $iSmooth)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "handle", $hGraphic, "int", $iSmooth)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_GraphicsSetSmoothingMode_New

    [/autoit]