Func _Metro_DropDownMenu($hWndParent, $mWidth, ByRef $ButtonsArray, ByRef $mMenuItems, $ControlID=-1, $OpenToTheRight=False, $StealthButton=False, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) Local $iButtonsArray[UBound($ButtonsArray)] Local $cbDPI = _HighDPICheck() Local $ButtonStep = (25 * $cbDPI) Local $cMarginR = Number(12 * $cbDPI, 1) If $ControlID <> -1 Then Local $mPos = __GUICtrlGetPos($hWndParent, $ControlID) If $OpenToTheRight Then $mPos[0] += $cMarginR / 2 + $mPos[2] -2 $mPos[1] += $mPos[3] - ($cMarginR / 2) - $ButtonStep Else $mPos[1] += $mPos[3] EndIf Else Local $mPos = MouseGetPos() EndIf Local $DesktopSize = _GetDesktopWorkArea($hWndParent, False) If @error Then Return ;Fix position if it is offscreen Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + $cMarginR If $mPos[0] + $mWidth > $DesktopSize[2] Then $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) EndIf If $mPos[1] + $mHeight > $DesktopSize[3] Then $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) EndIf Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $hWndParent) _Metro_AddWindows11StyleCorners($MenuForm) Local $Menu_Color If StringInStr($GUI_Theme_Name, "Light") Then $Menu_Color = _AlterBrightness($GUIThemeColor, -10) GUISetBkColor($Menu_Color, $MenuForm) Else $Menu_Color = _AlterBrightness($GUIThemeColor, +10) GUISetBkColor($Menu_Color, $MenuForm) EndIf For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 $iButtonsArray[$iB] = _Metro_CreateButtonAdvanced($ButtonsArray[$iB], $cMarginR / 2, $cMarginR / 2 + $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $Menu_Color, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle, False, $StealthButton) Next GUISetState(@SW_SHOW, $MenuForm) If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode While 1 If Not WinActive($MenuForm) Then GUIDelete($MenuForm) If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode Return SetError(1, 0, "") EndIf Local $imsg = GUIGetMsg() ; If $imsg = $GUI_EVENT_CLOSE Then GUIDelete($MenuForm) For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 If $imsg = $iButtonsArray[$iB] Then ; GUIDelete($MenuForm) If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode If MapExists($mMenuItems,$ButtonsArray[$iB]) Then Local $sPick = _Metro_DropDownMenu($MenuForm, 120, $mMenuItems[$ButtonsArray[$iB]], $mMenuItems, $imsg, True) If @error Then ContinueLoop GUIDelete($MenuForm) Return $sPick Else GUIDelete($MenuForm) Return $ButtonsArray[$iB] EndIf EndIf Next WEnd EndFunc ;==>_Metro_MenuBox Func _Metro_AddTitlebar($Text="",$MinimumWidth=0,$ErrorCorrection=0) GUICtrlCreateLabel("",0,0,480,31) GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 10)) GUICtrlSetState(-1, $GUI_DISABLE) Local $FRect = _StringSize($Text, 12, 800, 2, "Arial") If @error Then Return SetError(2,0,False) Local $Width = $FRect[2]<$MinimumWidth ? $MinimumWidth : $FRect[2]+$ErrorCorrection GUICtrlCreateLabel($Text,8,8,$Width,25) GUICtrlSetFont(-1,12,800,2,"Arial",5) GUICtrlSetColor(-1,$FontThemeColor) GUICtrlSetBkColor(-1,_AlterBrightness($GUIThemeColor, 10)) _Metro_AddHSeperator(0,31,480,2) EndFunc Func _Metro_AddWindowControlButtons($HasTitleBar=-1) ; CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True Local $NonActiveButtonColor = $HasTitleBar=-1 ? $GUIThemeColor : _AlterBrightness($GUIThemeColor, 10) Local $Control_Buttons = _Metro_AddControlButtons(True, True, True, False, False,$NonActiveButtonColor) $GUI_CLOSE_BUTTON = $Control_Buttons[0] $GUI_MAXIMIZE_BUTTON = $Control_Buttons[1] $GUI_RESTORE_BUTTON = $Control_Buttons[2] $GUI_MINIMIZE_BUTTON = $Control_Buttons[3] $METRO_FULLSCREEN_BUTTON = $Control_Buttons[4] $METRO_FSRestore_BUTTON = $Control_Buttons[5] $METRO_MENU_BUTTON = $Control_Buttons[6] EndFunc Func _Metro_AddWindows11StyleCorners($hWnd, $iData=2, $iAttribute=33) Switch $iAttribute Case 2, 3, 4, 6, 7, 8, 10, 11, 12, 33 ; Nothing Case Else Return SetError(1, 0, 0) EndSwitch Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, _ 'dword*', $iData, 'dword', 4) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then Return SetError(10, $aCall[0], 0) Return 1 EndFunc ;==>_WinAPI_DwmSetWindowAttribute Func _Metro_CreateInput($Text, $x, $y, $w=174, $h=24, $borderColor=-1, $stroke=6, $Fontsize=12) If $borderColor = -1 Then $borderColor = $ButtonBKColor ; Draw border _Metro_CreateUnderlinedRoundedRectangle("", $x - $stroke, $y - $stroke, $w + ($stroke * 2), $h + ($stroke * 2), 0xFFFFFF, $borderColor,True) ; Create input Local $InputBoxId = GUICtrlCreateInput($Text, $x, $y, $w, $h, -1, $WS_EX_WINDOWEDGE) GUICtrlSetFont(-1, $Fontsize, 800, 2, "Segoe UI", $Fontsize) GUICtrlSetColor(-1, 0xA0A0A0) GUICtrlSetCursor(-1, 0) Return $InputBoxId EndFunc Func _Metro_CreateUnderlinedRoundedRectangle($Text, $Left, $Top, $Width, $Height, $ButtonFaceColor=-1, $UnderlineColor=-1, $OutlineShape=-1, $Padding=-1) If $ButtonFaceColor=-1 Then $ButtonFaceColor = $ButtonBKColor If $UnderlineColor=-1 Then $UnderlineColor = _AlterBrightness($ButtonFaceColor, +90) If $OutlineShape=-1 Then $OutlineShape = False If $Padding=-1 Then $Padding = 0 Return _Metro_CreateRoundedRectangleEx($Text, $Left, $Top, $Width, $Height, $ButtonFaceColor, $GUIThemeColor, -1, $ButtonTextColor, -1, -1, -1, "Underlined", $UnderlineColor, $OutlineShape, $Padding) EndFunc Func _Metro_CreateMenuStrip($Text, $Left, $Top, $Width, $Height=-1, $Btn_Face_Color=-1, $Menu_Color=-1) If $Height=-1 Then $Height=31 If $Menu_Color=-1 Then $Menu_Color=$GUIThemeColor Return _Metro_CreateRoundedRectangleEx($Text, $Left, $Top, $Width, $Height, $Btn_Face_Color, $Menu_Color) EndFunc ;==>_Metro_CreateOnOffToggleW11 Func _Metro_CreateRoundedRectangleEx($Text, $Left, $Top, $Width, $Height, $Btn_Face_Color=-1, $Menu_Color=-1, $FontAlignment=-1, $Font_Color=-1, $Font=-1, $Fontsize=-1, $FontStyle=-1, $RectangleStyle=-1, $UnderlineColor=-1, $OutlineShape=-1, $Padding=-1) If $Padding=-1 Then $Padding=0 ; This creates by default a button that does not react to clicks Local $btnDPI = _HighDPICheck() If $HIGHDPI_SUPPORT Then $Left = Round($Left * $gDPI) $Top = Round($Top * $gDPI) $Width = Round($Width * $gDPI) $Height = Round($Height * $gDPI) Else $Fontsize = ($Fontsize / $Font_DPI_Ratio) EndIf If $Padding Then $Left-=$Padding $Top-=$Padding $Width+=$Padding * 2 $Height+=$Padding * 2 EndIf If $Btn_Face_Color=-1 Then $Btn_Face_Color=$ButtonBKColor If $FontAlignment=-1 Then $FontAlignment=0 If $Font_Color=-1 Then $Font_Color=$ButtonTextColor If $Font=-1 Then $Font="Arial" If $Fontsize=-1 Then $Fontsize=10 If $FontStyle=-1 Then $FontStyle=0 If $RectangleStyle=-1 Then $RectangleStyle="Normal" If $UnderlineColor=-1 Then $UnderlineColor="0x404040" If $OutlineShape=-1 Then $OutlineShape=False ;Set Colors If StringInStr($GUI_Theme_Name, "Light") Then Local $Font_Color1 = _AlterBrightness($Font_Color, 7) Else Local $Font_Color1 = _AlterBrightness($Font_Color, -15) EndIf If $Menu_Color=-1 Then If $Btn_Face_Color=$ButtonBKColor Then $Menu_Color = _AlterBrightness($Btn_Face_Color, -30) Else $Menu_Color = $GUIThemeColor EndIf EndIf $Btn_Face_Color = "0xFF" & Hex($Btn_Face_Color, 6) $Font_Color = "0xFF" & Hex($Font_Color, 6) $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) ;Create Button graphics Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($Menu_Color, "0x", "0xFF"), 5, 5) ;Hover If $RectangleStyle <> "Underlined" Then __DropShadowOnNormalButton(1,$Width, $Height,$Button_Graphic2) Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) Local $hPath = _GDIPlus_PathCreate() Switch $RectangleStyle Case "Underlined" ; Normal button shaped path with truncated bottom Local $iShortHeight = $iHeight - $iRadius ; new height without bottom arcs _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) ; Top-right _GDIPlus_PathAddLine($hPath, $Margin + $iWidth, $Margin + $iRadius, $Margin + $iWidth, $Margin + $iShortHeight) ; Right side _GDIPlus_PathAddLine($hPath, $Margin + $iWidth, $Margin + $iShortHeight, $Margin, $Margin + $iShortHeight) ; Bottom line (higher) _GDIPlus_PathAddLine($hPath, $Margin, $Margin + $iShortHeight, $Margin, $Margin + $iRadius) ; Left side _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) ; Top-left _GDIPlus_PathCloseFigure($hPath) ; Underline path Local $hPath1 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath1, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath1, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathCloseFigure($hPath1) Case Else _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath) EndSwitch If $OutlineShape Then ; Draw frame Local $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsDrawPath($Button_Graphic2[0], $hPath, $hPen) _GDIPlus_PenDispose($hPen) EndIf Switch $RectangleStyle Case "Underlined" Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace($Btn_Face_Color, "0x", "0xFF")) ; Rectangle face _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic2[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) Local $hBrushLine = _GDIPlus_BrushCreateSolid(StringReplace($UnderlineColor, "0x", "0xFF")) ; Rectangle underline _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic2[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath1, $hBrushLine) _GDIPlus_BrushDispose($hBrushLine) _GDIPlus_PathDispose($hPath1) Case Else Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace($Btn_Face_Color, "0x", "0xFF")) ; StringReplace(_AlterBrightness($Btn_Face_Color, +25) _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic2[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) EndSwitch ;Create font, Set font options Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) Local $tLayout = _GDIPlus_RectFCreate(8 * $gDPI, 0, $Width, $Height) _GDIPlus_StringFormatSetAlign($hFormat, $FontAlignment) ; 0=left, 1=centered, 2=right _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;Draw button text _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) ;Release created objects _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($Brush_BTN_FontColor) _GDIPlus_BrushDispose($hBrushHover) _GDIPlus_PathDispose($hPath) ;Set graphic and return Bitmap handle $ButtonShape = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) GUICtrlSetState(-1,$GUI_DISABLE) $Shape2 = _iGraphicCreateBitmapHandle($ButtonShape, $Button_Graphic2, False) _WinAPI_DeleteObject(GUICtrlSendMsg($ButtonShape, 0x0172, 0, $Shape2)) ;Button default image ;Set GUI Resizing GUICtrlSetResizing($ButtonShape, 768) Return $ButtonShape EndFunc ;==>_Metro_CreateRoundedRectangleEx Func _Metro_CreateMenuButton($Text, $Left, $Top, $Width, $Height=-1) If $Height=-1 Then $Height=28 Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height) EndFunc ;==>_Metro_CreateOnOffToggleW11 Func _Metro_CreateMenuButtonIcon($Text, $Left, $Top, $Width=-1, $Height=-1, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=16) If $Width = -1 Then $Width = 28 If $Height = -1 Then $Height = 28 If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $Menu_Color, $Btn_Face_Color, $Font_Color, $Font, $Fontsize) EndFunc ;==>_Metro_CreateButtonIconMenu Func _Metro_CreateButtonIconRound($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=16) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, $Fontsize, 0 , "Round","Normal") EndFunc ;==>_Metro_CreateButtonIconRound Func _Metro_CreateButtonIconStealth($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=16) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" If $Menu_Color = -1 Then $Menu_Color = $GUIThemeColor Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $Menu_Color, $Btn_Face_Color, $Font_Color, $Font, $Fontsize) EndFunc ;==>_Metro_CreateButtonIconStealth Func _Metro_CreateButtonIconStealthRound($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=16) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" If $Menu_Color = -1 Then $Menu_Color = $GUIThemeColor Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $Menu_Color, $Btn_Face_Color, $Font_Color, $Font, $Fontsize, 0 , True) EndFunc ;==>_Metro_CreateButtonIconRoundStealth Func _Metro_CreateButtonStealth($Text, $Left, $Top, $Width, $Height, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Arial" If $Menu_Color = -1 Then $Menu_Color = $GUIThemeColor Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $Menu_Color, $Btn_Face_Color, $Font_Color, $Font, $Fontsize) EndFunc ;==>_Metro_CreateButtonStealth Func _Metro_CreateButtonFlat($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Arial" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, $Fontsize, 0 , "Flat","Normal") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateButtonWindow11($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Arial" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, $Fontsize, 0 , "Window11","Normal") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateRainbowButtonWindow11($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Arial" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, $Fontsize, 0 , "Window11","Rainbow") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateButtonLeft($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Arial" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, 10, 0, "Lefty", "Normal") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateButtonCenter($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, 10, 0, "Center", "Normal") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateButtonRight($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, 10, 0, "Righty", "Normal") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateRainbowButtonLeft($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Arial" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, 10, 0, "Lefty", "Rainbow") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateRainbowButtonCenter($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, 10, 0, "Center", "Rainbow") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateRainbowButtonRight($Text, $Left, $Top, $Width=29, $Height=29, $Btn_Face_Color=-1, $Menu_Color=-1, $Font=-1, $Font_Color=-1, $Fontsize=10) If $Btn_Face_Color = -1 Then $Btn_Face_Color = $ButtonBKColor If $Font_Color = -1 Then $Font_Color = $ButtonTextColor If $Font = -1 Then $Font = "Segoe MDL2 Assets" Return _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $GUIThemeColor, $Btn_Face_Color, $Font_Color, $Font, 10, 0, "Righty", "Rainbow") EndFunc ;==>_Metro_CreateButtonWindow11Style Func _Metro_CreateWindows11OnOff($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $ButtonBKColor=$ButtonBKColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") Local $arg = StringSplit($Text,"|") If @error Or $arg[0]<>2 Then Return SetError(1,0,False) Return _Metro_CreateToggleW11($arg[1] & "|@|" & $arg[2], $Left, $Top, $Width, $Height, $BG_Color, $ButtonBKColor, $Font_Color, $Font, $Fontsize) EndFunc ;==>_Metro_CreateOnOffToggleW11 Func _Metro_CreateButtonAdvanced($Text, $Left, $Top, $Width, $Height, $Menu_Color=-1, $Btn_Face_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 0, $ButtonShape = -1, $BrushMode="Stealth", $GradientColor1=0xFFFF0000, $GradientColor2=0xFF4020FF, $Image="") ; By default, without optional parameters, this function will create a menu button Local $Button_Array[16] If $ButtonShape=-1 Then Local $Shadow1 = 0 Else Local $Shadow1 = .5666 * $gDPI EndIf Local $btnDPI = _HighDPICheck() If $HIGHDPI_SUPPORT Then $Left = Round($Left * $gDPI) $Top = Round($Top * $gDPI) $Width = Round($Width * $gDPI) $Height = Round($Height * $gDPI) Else $Fontsize = ($Fontsize / $Font_DPI_Ratio) EndIf $Button_Array[1] = False ; Set hover OFF $Button_Array[3] = "2" ; Type $Button_Array[15] = GetCurrentGUI() If StringInStr($GUI_Theme_Name, "Light") Then Local $Font_Color1 = _AlterBrightness($Font_Color, 7) Else Local $Font_Color1 = _AlterBrightness($Font_Color, -15) EndIf ; Darken the font for Stealth buttons if the background is too light If Not __IsDarkColor($Font_Color) And Not __IsDarkColor($GUIThemeColor) And $Menu_Color<>-1 And $BrushMode="Stealth" Then $Font_Color1 = 0x404040 EndIf ;Set Colors If $Menu_Color = -1 Then $Menu_Color = $Btn_Face_Color $Btn_Face_Color = "0xFF" & Hex($Btn_Face_Color, 6) $Font_Color = "0xFF" & Hex($Font_Color, 6) $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) ;Create Button graphics Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($Menu_Color, "0x", "0xFF"), 5, 5) ;Default Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($Menu_Color, "0x", "0xFF"), 5, 5) ;Hover Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled ; Button Path Local $iRadius = 5, $Margin = ($iRadius / 2) * $gDPI Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) Local $hPath = _GDIPlus_PathCreate() Switch $ButtonShape Case "Round" _GDIPlus_PathAddEllipse($hPath, 0, 0, $Width-1, $Height-1) Case "Lefty" _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathAddLine($hPath, $Width, $Margin, $Width, $Margin + $iHeight) _GDIPlus_PathCloseFigure($hPath) Case "Center" _GDIPlus_PathAddLine($hPath, $Width, $Margin, $Width, $Margin + $iHeight) _GDIPlus_PathAddLine($hPath, -1, $Margin + $iHeight, -1, $Margin) _GDIPlus_PathCloseFigure($hPath) Case "Righty" _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddLine($hPath, -1, $Margin + $iHeight, -1, $Margin) _GDIPlus_PathCloseFigure($hPath) Case "Flat" _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) ; top right _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) ; bottom right _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) ; bottom left _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) ; top left _GDIPlus_PathCloseFigure($hPath) Case "Window11" ; Draw frame Local $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsDrawPath($Button_Graphic1[0], $hPath, $hPen) _GDIPlus_PenDispose($hPen) __DropShadowOnNormalButton($Shadow1,$Width,$Height,$Button_Graphic1) _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) ; top right _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) ; bottom right _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) ; bottom left _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) ; top left _GDIPlus_PathCloseFigure($hPath) Case Else ; Menu Button ;__DropShadowOnNormalButton($Shadow1,$Width,$Height,$Button_Graphic1) _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath) EndSwitch Switch $BrushMode Case "Stealth" ; Color Normal button state the same color as backgroud Local $hBrush = _GDIPlus_BrushCreateSolid(StringReplace($Menu_Color, "0x", "0xFF")) Case "Rainbow" ; Draw frame Local $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsDrawPath($Button_Graphic1[0], $hPath, $hPen) _GDIPlus_GraphicsDrawPath($Button_Graphic2[0], $hPath, $hPen) _GDIPlus_PenDispose($hPen) ; Create linear gradient brush Local $hBrush = _GDIPlus_LineBrushCreate($Height*2, $Height*2, 0, 0, $GradientColor1, $GradientColor2, 3) Case Else ; "Normal" ; Create solid color brush Local $hBrush = _GDIPlus_BrushCreateSolid(StringReplace($Btn_Face_Color, "0x", "0xFF")) EndSwitch ; Color the hover face brighter Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Btn_Face_Color, +25), "0x", "0xFF")) ; Color all the button faces for normal, hover, and disabled states _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic1[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; antialiasing _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic2[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic3[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) ; Add a button image to the left side If $Image <> "" Then Local $hImage = _GDIPlus_ImageLoadFromFile($Image) If @error Then MsgBox(0, "Error", "Failed to load image. Please use a PNG or JPG file.") Else Local $iNewW = $iHeight - 7 * $gDPI, $iNewH = $iHeight - 7 * $gDPI Local $hResized = _GDIPlus_ImageResize($hImage, $iNewW, $iNewH) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDrawImage($Button_Graphic1[0], $hResized, $Margin + 4 * $gDPI, $Margin + 4 * $gDPI) _GDIPlus_GraphicsDrawImage($Button_Graphic2[0], $hResized, $Margin + 4 * $gDPI, $Margin + 4 * $gDPI) _GDIPlus_GraphicsDrawImage($Button_Graphic3[0], $hResized, $Margin + 4 * $gDPI, $Margin + 4 * $gDPI) _GDIPlus_ImageDispose($hResized) EndIf EndIf ;Create font, Set font options Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) Local $tLayout = _GDIPlus_RectFCreate(1, 1, $Width, $Height) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;Draw button text _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) ;Release created objects _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($Brush_BTN_FontColor) _GDIPlus_BrushDispose($Brush_BTN_FontColor1) _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrushHover) _GDIPlus_PathDispose($hPath) ;Set graphic and return Bitmap handle $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height + $Shadow1) $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) ; Prevent button image from resizing GUICtrlSetResizing($Button_Array[0], 768) _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) Return $Button_Array[0] EndFunc ;==>_Metro_CreateButtonAdvanced Func _Metro_CreateToggleW11($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $ButtonBKColor=$ButtonBKColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") Local $Text1 = $Text If $Height < 20 Then If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") EndIf If $Width < 46 Then If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") EndIf If Not (Mod($Height, 2) = 0) Then If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") EndIf ;HighDPI Support Local $pDPI = _HighDPICheck() If $HIGHDPI_SUPPORT Then $Left = Round($Left * $gDPI) $Top = Round($Top * $gDPI) $Width = Round($Width * $gDPI) $Height = Round($Height * $gDPI) If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 Else $Fontsize = ($Fontsize / $Font_DPI_Ratio) EndIf Local $Toggle_Array[16] $Toggle_Array[1] = False ; Hover $Toggle_Array[2] = False ; Checked State $Toggle_Array[3] = "6" ; Type $Toggle_Array[15] = GetCurrentGUI() ;Calc pos/sizes Local $TopMargCalc = Number(20 * $pDPI, 1) If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 Local $TopMargCalc1 = Number(12 * $pDPI, 1) If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) Local $iRadius = 10 * $pDPI Local $hFWidth = Number(50 * $pDPI, 1) ; 50 If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 Local $togSizeW = Number(46 * $pDPI, 1) ; 46 If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 Local $togSizeH = Number(20 * $pDPI, 1) If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 Local $tog_calc1 = Number(2 * $pDPI, 1) Local $tog_calc2 = Number(3 * $pDPI, 1) Local $tog_calc3 = Number(11 * $pDPI, 1) Local $tog_calc5 = Number(6 * $pDPI, 1) ;Set Colors $BG_Color = "0xFF" & Hex($BG_Color, 6) $Font_Color = "0xFF" & Hex($Font_Color, 6) Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) If StringInStr($GUI_Theme_Name, "Light") Then Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") Else Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") EndIf ;Unchecked (UC) Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 1 * $pDPI) Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 1 * $pDPI) ;Checked (C) Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +30), "0x", "0xFF")) Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF")) ; StringReplace($ButtonBKColor_BACKUP, "0x", "0xFF") Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) ;Create graphics Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;Set font options Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) _GDIPlus_StringFormatSetAlign($hFormat, 0) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;Draw text If StringInStr($Text, "|@|") Then $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) If Not @error Then $Text1 = $Text1[0] $Text = StringRegExp($Text, "^(.+)\|@\|", 1) If Not @error Then $Text = $Text[0] EndIf _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) ;Default state Local $hPath1 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath1) _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) ;Default hover state Local $hPath2 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath2) _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) ;~ _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleHoverUC) ;CheckedStep1 Local $hPath3 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath3) _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleHoverUC) ;CheckedStep2 Local $hPath4 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath4) _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleHoverUC) ;CheckedStep3 Local $hPath5 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath5) _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleHoverUC) ;CheckedStep4 Local $hPath6 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath6) _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleHoverUC) ;CheckedStep5 Local $hPath7 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath7) _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleC) ;CheckedStep6 Local $hPath8 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath8) _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleC) ;Final checked state Local $hPath9 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath9) _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) ;Final checked state hover Local $hPath10 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath10) _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI -2, $TopMarginCircle -2, 16 * $pDPI, 16 * $pDPI, $BrushCircleC) ;Release created objects _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($Brush_BTN_FontColor) _GDIPlus_BrushDispose($Brush_BTN_FontColor1) _GDIPlus_BrushDispose($BrushInnerUC) _GDIPlus_BrushDispose($BrushCircleUC) _GDIPlus_BrushDispose($BrushCircleHoverUC) _GDIPlus_BrushDispose($BrushInnerC) _GDIPlus_BrushDispose($BrushInnerCHover) _GDIPlus_BrushDispose($BrushCircleC) _GDIPlus_PenDispose($hPenDefaultUC) _GDIPlus_PenDispose($hPenHoverUC) _GDIPlus_PenDispose($hPenDefaultC) _GDIPlus_PenDispose($hPenHoverC) _GDIPlus_PathDispose($hPath1) _GDIPlus_PathDispose($hPath2) _GDIPlus_PathDispose($hPath3) _GDIPlus_PathDispose($hPath4) _GDIPlus_PathDispose($hPath5) _GDIPlus_PathDispose($hPath6) _GDIPlus_PathDispose($hPath7) _GDIPlus_PathDispose($hPath8) _GDIPlus_PathDispose($hPath9) _GDIPlus_PathDispose($hPath10) ;Create bitmap handles and set graphics $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) ;Set Control Resizing GUICtrlSetResizing($Toggle_Array[0], 768) ;Add to GUI_HOVER_REG _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) Return $Toggle_Array[0] EndFunc ;==>_Metro_CreateToggleW11 Func __IsDarkColor($iColor) Local $r = BitShift(BitAND($iColor, 0xFF0000), 16) Local $g = BitShift(BitAND($iColor, 0x00FF00), 8) Local $b = BitAND($iColor, 0x0000FF) ; Calculate perceived brightness Local $brightness = Sqrt(0.299 * $r ^ 2 + 0.587 * $g ^ 2 + 0.114 * $b ^ 2) Return $brightness < 130 ; threshold: tweak as needed EndFunc Func __DropShadowOnNormalButton($Shadow1,$Width,$Height, ByRef $Button_Graphic1) Local $iRadius = 5, $Margin = ($iRadius / 2) * $gDPI Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath, _ $Margin + $iWidth - ($iRadius * 2), $Margin + $Shadow1, _ $iRadius * 2, $iRadius * 2 + $Shadow1 _ , 270, 90) _GDIPlus_PathAddArc($hPath, _ $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2) + $Shadow1, _ $iRadius * 2, $iRadius * 2 + $Shadow1 _ , 0, 90) _GDIPlus_PathAddArc($hPath, _ $Margin, $Margin + $iHeight - ($iRadius * 2) + $Shadow1, _ $iRadius * 2, $iRadius * 2 + $Shadow1 _ , 90, 90) _GDIPlus_PathAddArc($hPath, _ $Margin, $Margin + $Shadow1, _ $iRadius * 2, $iRadius * 2 + $Shadow1 _ , 180, 90) _GDIPlus_PathCloseFigure($hPath) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF808080) _GDIPlus_GraphicsSetSmoothingMode($Button_Graphic1[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) _GDIPlus_GraphicsFillPath($Button_Graphic1[0],$hPath,$hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PathDispose($hPath) EndFunc ;==>DropShadow Func __GUICtrlGetPos($hWndParent,$ControlID) Local $mPos = ControlGetPos("","",$ControlID) If @error Then Return SetError(1,0,-1) $cPos = DllStructCreate($tagPOINT) If @error Then Return SetError(2,0,-1) $cPos.X = $mPos[0] $cPos.Y = $mPos[1] _WinAPI_ClientToScreen($hWndParent,$cPos) If @error Then Return SetError(3,0,-1) $mPos[0] = $cPos.X $mPos[1] = $cPos.Y Return $mPos EndFunc