Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Color.au3>
#include <StringSize.au3> ; http://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/
$color1 = 0x000000
$color2 = 0x00f0ff
$gui = GUICreate("Gradient Demo")
$size = WinGetClientSize($gui)
_GUICtrlCreateGradient($color1, $color2, 0, 0, $size[0], $size[1])
_GUICtrlCreateGroup("Mon groupe", 10, 10, 150, 150, 0xffffff)
_GUICtrlCreateGroup("Mon deuxième groupe", 10, 180, 150, 150, 0x886600, 0, 0, 1)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = -3 Then Exit
Wend
Func _GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $bColor = 0x000000, $bBkColor = -2, $iStyle = 1, $iBorder = 0)
Local $aLabel[6] = [5], $iCStyle
Local $aStringSize = _StringSize($sText)
If $iStyle Then $iCStyle = $SS_SUNKEN
$aLabel[1] = GUICtrlCreateLabel('', $iLeft + 1, $iTop, 9, 2, $iCStyle) ; Top Left Line.
$aLabel[2] = GUICtrlCreateLabel('', $iLeft + $aStringSize[2] + 10, $iTop, $iWidth - $aStringSize[2] - 10, 2, $iCStyle) ; Top Right Line.
$aLabel[3] = GUICtrlCreateLabel('', $iLeft, $iTop + 2, 2, $iHeight - 4, $iCStyle) ; Left Line.
$aLabel[4] = GUICtrlCreateLabel('', $iLeft + $iWidth - 2, $iTop + 2, 2, $iHeight - 4, $iCStyle) ; Right Line.
$aLabel[5] = GUICtrlCreateLabel('', $iLeft + 1, $iTop + $iHeight - 2, $iWidth - 2, 2, $iCStyle) ; Bottom Line.
For $i = 1 To $aLabel[0]
GUICtrlSetBkColor($aLabel[$i], $bColor)
GUICtrlSetBkColor($aLabel[$i], $bColor)
Next
GUICtrlCreateLabel("", $iLeft + 2, $iTop + 2, $iWidth - 4, $iHeight - 4)
GUICtrlSetBkColor(-1, $bBkColor)
GUICtrlCreateLabel($sText, $iLeft + 12, $iTop - 6, $aStringSize[2], 15, $SS_CENTER)
GUICtrlSetBkColor(-1, $bBkColor)
GUICtrlSetColor(-1, $bColor)
If $iBorder Then
GUICtrlCreateLabel("", $iLeft + 10, $iTop - 6, 2, 8, $iCStyle)
GUICtrlSetBkColor(-1, $bColor)
GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 10, $iTop - 6, 2, 8, $iCStyle)
GUICtrlSetBkColor(-1, $bColor)
GUICtrlCreateLabel("", $iLeft + 10, $iTop - 8, $aStringSize[2] + 2, 2, $iCStyle)
GUICtrlSetBkColor(-1, $bColor)
EndIF
EndFunc ;==>_GUICtrlCreateGroup
Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
Local $color1R = _ColorGetRed($nStartColor)
Local $color1G = _ColorGetGreen($nStartColor)
Local $color1B = _ColorGetBlue($nStartColor)
Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight
GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
For $i = 0 To $nHeight - $nY
$sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
Next
EndFunc