I modified one of my old script from 2014:
;Coded by UEZ
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172
Global Const $hGUI = GUICreate("GDI+ Test", 200, 100)
GUISetBkColor(0x505050)
Global Const $iPicBtn = GUICtrlCreatePic("", 50, 28, 100, 44)
Global $aButtons = _GDIPlus_BitmapCreateRoundedButtonAndText("install", 100, 44)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0]))
GUISetState()
Global $aMouseInfo, $bShow = False, $bHide = False
Do
If WinActive($hGUI) Then
$aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation
Switch $aMouseInfo[4]
Case $iPicBtn
_WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1]))
$bShow = True
$bHide = False
Case Else
_WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0]))
$bHide = True
$bShow = False
EndSwitch
EndIf
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_WinAPI_DeleteObject($aButtons[0])
_WinAPI_DeleteObject($aButtons[1])
_GDIPlus_Shutdown()
Exit
Case $iPicBtn
MsgBox(0, "Information", "Button pressed")
EndSwitch
Until False
; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapCreateRoundedButtonAndText
; Description ...: Draw rounded button
; Syntax ........: _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[,
; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]])
; Parameters ....: $sString - A string value.
; $iWidth - An integer value.
; $iHeight - An integer value.
; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1.
; $iFontSize - [optional] An integer value. Default is 16.
; $sFont - [optional] A string value. Default is "Times New Roman".
; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C.
; $iFrameSize - [optional] An integer value. Default is 2.
; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA.
; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF.
; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button
; Author ........: UEZ
; Version .......: 0.85 build 2025-01-12
; Modified ......:
; Remarks .......: Dispose returned GDI bitmap handles when done
; Example .......: Yes
; ===============================================================================================================================
Func _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xF0FFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF)
;some checks
If $sString = "" Then Return SetError(1, 0, 0)
If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0)
If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0)
;create font objects
Local Const $hFormat = _GDIPlus_StringFormatCreate()
Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight)
_GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis
_GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis
;create bitmap and graphics context handles
Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)]
Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])]
;set drawing quality
_GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY)
_GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[1], $GDIP_SMOOTHINGMODE_HIGHQUALITY)
_GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT)
;define brush and pen objects
Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) ;, $hBrushBGColor = _GDIPlus_BrushCreateSolid($iBgColor)
Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, $iFrameSize), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize)
;create path object
Local Const $hPath = _GDIPlus_PathCreate()
;create cloned path object for string measurement
Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath)
_GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat)
_GDIPlus_PathStartFigure($hPath)
Local $fArcSize = $iWidth * 0.33333
_GDIPlus_PathAddArc($hPath, $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, 180, -90) ;BR
_GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, -270, -90) ;BL
_GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, 0, -90) ;TR
_GDIPlus_PathAddArc($hPath, $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, -90, -90) ;TL
_GDIPlus_PathCloseFigure($hPath)
Local Const $hPath_Clone = _GDIPlus_PathClone($hPath)
Local Const $hBrushBGColor = _GDIPlus_PathBrushCreateFromPath($hPath)
_GDIPlus_PathBrushSetSurroundColor($hBrushBGColor, $iBgColor)
_GDIPlus_PathBrushSetCenterColor($hBrushBGColor, 0xFFFFFFFF)
_GDIPlus_PathBrushSetCenterPoint($hBrushBGColor, $iWidth / 2, $iHeight / 2)
_GDIPlus_PathBrushSetSigmaBlend($hBrushBGColor, 1, 0.33333)
_GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushBGColor)
_GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor)
_GDIPlus_PathReset($hPath)
;add string to path
_GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat)
;clear bitmap and draw string
_GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor)
_GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor)
;draw rectangle on cloned bitmap for hover effect
_GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight)
_GDIPlus_GraphicsDrawPath($aGfxCtxt[1], $hPath_Clone, $hPenHoverColor)
;dispose object resources
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_PathDispose($hPath)
_GDIPlus_PathDispose($hPath_Dummy)
_GDIPlus_PathDispose($hPath_Clone)
_GDIPlus_GraphicsDispose($aGfxCtxt[0])
_GDIPlus_GraphicsDispose($aGfxCtxt[1])
_GDIPlus_BrushDispose($hBrushFontColor)
_GDIPlus_BrushDispose($hBrushBGColor)
_GDIPlus_PenDispose($hPenFontFrameColor)
_GDIPlus_PenDispose($hPenHoverColor)
;create GDI bitmap for later usage
Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])]
;dispose GDI+ bitmaps
_GDIPlus_BitmapDispose($aBitmaps[0])
_GDIPlus_BitmapDispose($aBitmaps[1])
Return $aHBitmaps
EndFunc ;==>_GDIPlus_BitmapCreateRoundedButtonAndText