You can't round the corners of a label (Static control) with that code unless a class property of the Static control is removed.
You can remove the style, and it works, but there might be issues, these methods are better.
Look into the png gui methods on the forum for making smoother looking rounded forms and rounded labels.
Playlet has a vertical tab gui that uses a rounded png form with a drop shadow and rounded png labels
The GDI rounded labels have border and bodies with sharper aliased edges.
The GDI+ labels are anti-aliased and the border alpha can be set lower for a softer look.
;GDI - GDI+ round static control border frames and bodies
;coded by rover 2k12
;GDI+ code from Funkey and Wide Boy Dixon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
Global $aLblCtrl[1][4]
_Main
()
Func _Main
()
Local $Form1 = GUICreate("Testing", 790, 405, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_POPUP, $WS_GROUP))
_Gui
_RoundCorners
($Form1, 0, 0, 30, 30)
Local $Wow64 = ""
If @AutoItX64 Then $Wow64 = "\Wow6432Node"
Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\msoobe.jpg"
Local $cPic = GUICtrlCreatePic($sPath, 0, 0, 790, 405, 0)
GuiCtrlSetState(-1, $GUI_DISABLE)
;brushes and pens - stock object can be called as needed, handles are always the same for 2nd+ copies - handles do not have to be deleted.
Local $hBrushCol2 = _WinAPI_CreateSolidBrush(0x494949)
Local $hPen2 = _WinAPI_CreatePen($PS_SOLID, 1, 0xFF0000)
Local $c0 = GUICtrlCreateDummy(), $nMsg
GUICtrlDelete($c0)
ReDim $aLblCtrl[7+$c0][4]
$aLblCtrl[0][0] = $c0 ; set first element to first control ID
;GDI
$aLblCtrl[$c0][0] = GUICtrlCreateLabel("A", 100, 100, 44, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 800, 0, "Georgia", $ANTIALIASED_QUALITY)
$aLblCtrl[$c0][1] = 0x000000 ;default black text colour
$aLblCtrl[$c0][2] = 0x000000 ;default black pen border frame
$aLblCtrl[$c0][3] = _WinAPI_GetStockObject($LTGRAY_BRUSH) ;grey label background
$c0+=1
$aLblCtrl[$c0][0] = GUICtrlCreateLabel("B", 100, 180, 44, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 800, 0, "Georgia", $ANTIALIASED_QUALITY)
$aLblCtrl[$c0][1] = 0xF4F4F4 ;white text colour - BGR
$aLblCtrl[$c0][2] = $hPen2 ;blue pen border frame
$aLblCtrl[$c0][3] = _WinAPI_GetStockObject($NULL_BRUSH) ;transparent label background
$c0+=1
$aLblCtrl[$c0][0] = GUICtrlCreateLabel("C", 100, 260, 44, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 800, 0, "Georgia", $ANTIALIASED_QUALITY)
$aLblCtrl[$c0][1] = 0x00FFFF ;yellow text colour - BGR
$aLblCtrl[$c0][2] = _WinAPI_GetStockObject($NULL_PEN) ;transparent pen border frame - no border - rounded label body
$aLblCtrl[$c0][3] = $hBrushCol2 ;dark brown label background
$aLblCtrl[1][0] = $aLblCtrl[$c0][0] ; set second element to last control ID
$aLblCtrl[2][0] = _WinAPI_GetStockObject($NULL_BRUSH) ; set third element to null brush
$aLblCtrl[$c0+1][3] = 10 ; ellipse width
$aLblCtrl[$c0+2][3] = 10 ; ellipse height
$aLblCtrl[$c0+3][3] = DllOpen("gdi32.dll")
$aLblCtrl[$c0+4][3] = DllOpen("user32.dll")
;GDI+
GUICtrlCreateLabel("A", 200, 100, 44, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
_LabelMakeTranslucent
(-1, $cPic, 44, 49, 6, 0x205555f5, 0xEEf0f000, 0x77000000, 1, "", 16, "Georgia", BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlCreateLabel("B", 200, 180, 44, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
_LabelMakeTranslucent
(-1, $cPic, 44, 49, 6, 0xAA494949, 0xFF000000, 0x00000000, 1, "", 16, "Georgia", BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlCreateLabel("C", 200, 260, 44, 49, BitOR($SS_CENTER, $SS_CENTERIMAGE))
_LabelMakeTranslucent
(-1, $cPic, 44, 49, 6, 0x50000000, 0xFFFFFFFF, 0x77FFFFFF, 1, "", 16, "Georgia", BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUIRegisterMsg($WM_CTLCOLORSTATIC, '_WM_CTLCOLORSTATIC')
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case 0
Case $GUI_EVENT_CLOSE
;delete non-stock object resources - no need to delete stock objects on exit
_WinAPI_DeleteObject($hBrushCol2)
_WinAPI_DeleteObject($hPen2)
Exit
EndSwitch
WEnd
EndFunc
Func _WM
_CTLCOLORSTATIC
($hWnd, $msg, $wParam, $lParam)
#forceref $hWnd, $Msg
Local $hDC = $wParam, $iLast = $aLblCtrl[1][0]
Local $ID = DllCall($aLblCtrl[$iLast+4][3], "int", "GetDlgCtrlID", "hwnd", $lParam)
If @error Then Return $GUI_RUNDEFMSG
If $ID[0] < $aLblCtrl[0][0] Or $ID[0] > $aLblCtrl[1][0] Then Return $GUI_RUNDEFMSG ;filter out other labels or controls
DllCall($aLblCtrl[$iLast+3][3], "int", "SetBkMode", "handle", $hDC, "int", $TRANSPARENT) ;transparent text background
DllCall($aLblCtrl[$iLast+3][3], "int", "SetTextColor", "hwnd", $hDC, "int", $aLblCtrl[$ID[0]][1]) ;text colour
DllCall($aLblCtrl[$iLast+3][3], "handle", "SelectObject", "handle", $hDC, "handle", $aLblCtrl[$ID[0]][2]) ;border frame pen colour
DllCall($aLblCtrl[$iLast+3][3], "handle", "SelectObject", "handle", $hDC, "handle", $aLblCtrl[$ID[0]][3]) ;background fill colour
Local $aPos = ControlGetPos($lParam, '', $lParam)
DllCall($aLblCtrl[$iLast+3][3], 'int', 'RoundRect', 'handle', $hdc, 'int', 0, 'int', 0, 'int', $aPos[2]-1, 'int', $aPos[3]-1, 'int', $aLblCtrl[$iLast+1][3], 'int', $aLblCtrl[$iLast+2][3])
Return $aLblCtrl[2][0]
EndFunc ;==>_WM_CTLCOLORSTATIC
Func _Gui
_RoundCorners
($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
Local $XS_pos, $XS_ret, $XS_ret2
$XS_pos = WinGetPos($h_win)
$XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
If $XS_ret[0] Then
$XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
EndIf
EndFunc ;==>_Gui_RoundCorners
;code below from:
;Author: Funkey
;Translucent label on pic control
;http://www.autoitscript.com/forum/topic/133687-translucent-label-on-pic-control/
Func _LabelMakeTranslucent
($nLbl, $nPic, $iW = 0, $iH = 0, $iRadius = 0, $TransColor = 0x30FFFFFF, $FontColor = 0xFF000000, $Frame = 0xFF000000, $StartGdip = 1, $sText = "", $iSize = 8, $sFontName = "Arial", $iStyle = 0)
;Author: Funkey
Local $hLbl = GUICtrlGetHandle($nLbl)
Local $hPic = GUICtrlGetHandle($nPic)
Local $hImage = _SendMessage($hPic, 371)
Local $hParent = _WinAPI_GetParent($hLbl)
Local $Style = _WinAPI_GetWindowLong($hLbl, -16)
Local $iSS_CENTER = BitAND($Style, 0x1)
Local $iSS_RIGHT = BitAND($Style, 0x2)
Local $iSS_CENTERIMAGE = BitAND($Style, 0x200)
Local $IsPic = BitAND($Style, 0xE)
;ConsoleWrite($IsPic & @CR)
If $sText = "" Then $sText = GUICtrlRead($nLbl)
If $IsPic = 0xE Then
$iSS_CENTER = BitAND(GUICtrlRead($nLbl), 0x1)
$iSS_RIGHT = BitAND(GUICtrlRead($nLbl), 0x2)
$iSS_CENTERIMAGE = BitAND(GUICtrlRead($nLbl), 0x200)
Else
GUICtrlSetData($nLbl, $Style) ;remember the old style in text
If $iSS_CENTER Then $Style = BitXOR($Style, 0x1) ;delete SS_CENTER
_WinAPI_SetWindowLong($hLbl, -16, BitOR($Style, 0x200, 0xE))
EndIf
Local $aLblPos = ControlGetPos($hParent, "", $hLbl)
Local $aPicPos = ControlGetPos($hParent, "", $nPic)
If $StartGdip Then _GDIPlus_Startup()
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hImage)
Local $hBitmap2 = _GDIPlus_BitmapCloneArea($hBitmap, $aLblPos[0] - $aPicPos[0], $aLblPos[1] - $aPicPos[1], $aLblPos[2], $aLblPos[3])
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap2)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) ;Anti-Aliasing
Local $hBrushArea = _GDIPlus_BrushCreateSolid($TransColor)
_GDIPlus
_GraphicsDrawRoundRect
($hGraphics, 0, 0, $iW-3, $iH-3, $iRadius, $hBrushArea, $Frame)
;_GDIPlus_GraphicsFillRect($hGraphics, 0, 0, $aLblPos[2], $aLblPos[3], $hBrushArea)
Local $hBrushText = _GDIPlus_BrushCreateSolid($FontColor)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFontFamily = _GDIPlus_FontFamilyCreate($sFontName)
Local $hFont = _GDIPlus_FontCreate($hFontFamily, $iSize, $iStyle)
Local $tLayout = _GDIPlus_RectFCreate()
If $iSS_CENTERIMAGE Then DllStructSetData($tLayout, 2, $aLblPos[3] / 2 - $iSize + 4) ;vertical center
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat)
If $iSS_CENTER Then DllStructSetData($aInfo[0], 1, ($aLblPos[2] - DllStructGetData($aInfo[0], 3)) / 2) ;horizontal center
If $iSS_RIGHT Then DllStructSetData($aInfo[0], 1, $aLblPos[2] - DllStructGetData($aInfo[0], 3) - 1) ; right
_GDIPlus_GraphicsDrawStringEx($hGraphics, $sText, $hFont, $aInfo[0], $hFormat, $hBrushText)
Local $hImageNew = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2)
_WinAPI_DeleteObject(GUICtrlSendMsg($nLbl, 370, 0, $hImageNew))
_WinAPI_DeleteObject($hImageNew)
_GDIPlus_ImageDispose($hBitmap)
_GDIPlus_ImageDispose($hBitmap2)
_GDIPlus_BrushDispose($hBrushArea)
_GDIPlus_BrushDispose($hBrushText)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFontFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_GraphicsDispose($hGraphics)
If $StartGdip Then _GDIPlus_Shutdown()
EndFunc ;==>_LabelMakeTranslucent
;code below from:
;Author: Wide Boy Dixon
;_GDIPlus_GraphicsDrawRoundRect
;http://www.autoitscript.com/forum/topic/97362-gdiplus-graphicsdrawroundrect/
Func _GDIPlus
_GraphicsDrawRoundRect
($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius, $hBrush = 0, $hPen = 0)
;Author: Wide Boy Dixon
$hPen = _GDIPlus_PenCreate($hPen)
Local $hPath = _GDIPlus
_GraphicsPathCreate
()
_GDIPlus
_GraphicsPathAddLine
($hPath, $iX + $iRadius, $iY, $iX + $iWidth - ($iRadius * 2), $iY)
_GDIPlus
_GraphicsPathAddArc
($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90)
_GDIPlus
_GraphicsPathAddLine
($hPath, $iX + $iWidth, $iY + $iRadius, $iX + $iWidth, $iY + $iHeight - ($iRadius * 2))
_GDIPlus
_GraphicsPathAddArc
($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90)
_GDIPlus
_GraphicsPathAddLine
($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight, $iX + $iRadius, $iY + $iHeight)
_GDIPlus
_GraphicsPathAddArc
($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90)
_GDIPlus
_GraphicsPathAddLine
($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iX, $iY + $iRadius)
_GDIPlus
_GraphicsPathAddArc
($hPath, $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90)
_GDIPlus
_GraphicsPathCloseFigure
($hPath)
If $hBrush <> 0 Then _GDIPlus
_GraphicsFillPath
($hGraphics, $hBrush, $hPath)
_GDIPlus
_GraphicsDrawPath
($hGraphics, $hPen, $hPath)
_GDIPlus
_GraphicsPathDispose
($hPath)
_GDIPlus_PenDispose($hPen)
EndFunc
Func _GDIPlus
_GraphicsPathCreate
($iFillMode = 0)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $iFillMode, "int*", 0);
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, $aResult[2])
EndFunc
Func _GDIPlus
_GraphicsPathAddLine
($hGraphicsPath, $iX1, $iY1, $iX2, $iY2)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine", "hwnd", $hGraphicsPath, "float", $iX1, "float", $iY1, _
"float", $iX2, "float", $iY2)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc
Func _GDIPlus
_GraphicsPathAddArc
($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _
"float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc
Func _GDIPlus
_GraphicsPathCloseFigure
($hGraphicsPath)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hGraphicsPath)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc
Func _GDIPlus
_GraphicsPathDispose
($hGraphicsPath)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hGraphicsPath)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc
Func _GDIPlus
_GraphicsDrawPath
($hGraphics, $hPen, $hGraphicsPath)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphics, "hwnd", $hPen, "hwnd", $hGraphicsPath)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc
Func _GDIPlus
_GraphicsFillPath
($hGraphics, $hBrush, $hGraphicsPath)
;Author: Wide Boy Dixon
Local $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphics, "hwnd", $hBrush, "hwnd", $hGraphicsPath)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc