Danke Raupi, hab den Link repariert.
Schaut euch das mal an, was da ein Kanadier gebastelt hat:
Spoiler anzeigen
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Global $hGui = GUICreate("Test OwnTab-Style 5", 640, 200)
GUISetBkColor(0xFF080)
_OwnTab_Style5($hGui, 20, 60, 200, 125)
Global $bckpic = GUICtrlCreatePic("", 0, 0, 0, 0, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1, $GUI_DISABLE)
_GDIPlus_Startup()
$guibitmap = startbmp($hGui, 200, 125)
$guibitmap = _drawborder($guibitmap, 200, 125, 2, "0xffffff", "0x999999", 125/2) ;sets up the border on background
finalizectrl($bckpic, $guibitmap)
_OwnTab_Label("R.I.P.", 200, 125) ;<-- Das soll ein Scherz sein
_OwnTab_Label("Das ist ein Scherz", 200, 225) ;<-- Das soll ein Scherz sein
_OwnTab_Style5($hGui, 220, 60, 200, 45)
Global $bckpic = GUICtrlCreatePic("", 0, 0, 0, 0, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1, $GUI_DISABLE)
$guibitmap = startbmp($hGui, 200, 45)
$guibitmap = _drawborder($guibitmap, 200, 45, 2, "0x444444", "0x999999", 45/2) ;sets up the border on background
finalizectrl($bckpic, $guibitmap)
_OwnTab_Label("Tab2", 200, 45)
_OwnTab_Style5($hGui, 420, 60, 200, 45)
Global $bckpic = GUICtrlCreatePic("", 0, 0, 0, 0, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1, $GUI_DISABLE)
$guibitmap = startbmp($hGui, 200, 45)
$guibitmap = _drawborder($guibitmap, 200, 45, 2, "0xFF4444", "0x999999", 45/2) ;sets up the border on background
finalizectrl($bckpic, $guibitmap)
_GDIPlus_Shutdown()
_OwnTab_Label("Tab3", 200, 45)
GUISwitch($hGui)
GUISetState()
Local $msg
Do
$msg = GUIGetMsg()
If $msg > 0 Then MsgBox(0, "OwnTab", "You pressed tab with ID " & $msg & ".")
Until $msg = -3
Func _OwnTab_Label($sText, $iWidth, $iHeight, $iStyle = 0x201, $iExStyle = 0x0)
Local $Label = GUICtrlCreateLabel($sText, 0, 0, $iWidth, $iHeight, $iStyle, $iExStyle)
GUICtrlSetBkColor(-1, -2)
Return $Label
EndFunc ;==>_OwnTab_Label
Func _OwnTab_Pic($sFilename, $iWidth, $iHeight, $iStyle = 0x0, $iExStyle = 0x0)
Local $Pic = GUICtrlCreatePic($sFilename, 0, 0, $iWidth, $iHeight, $iStyle, $iExStyle)
GUICtrlSetState(-1, 128) ;$GUI_DISABLE
Return $Pic
EndFunc ;==>_OwnTab_Pic
Func _OwnTab_Gradient($nStartColor, $nEndColor, $iWidth, $iHeight)
Local $colorR = Dec(StringLeft(Hex($nStartColor, 6), 2))
Local $colorG = Dec(StringMid(Hex($nStartColor, 6), 3, 2))
Local $colorB = Dec(StringMid(Hex($nStartColor, 6), 5, 2))
Local $StepR = (Dec(StringLeft(Hex($nEndColor, 6), 2)) - $colorR) / ($iHeight - 1)
Local $StepG = (Dec(StringMid(Hex($nEndColor, 6), 3, 2)) - $colorG) / ($iHeight - 1)
Local $StepB = (Dec(StringMid(Hex($nEndColor, 6), 5, 2)) - $colorB) / ($iHeight - 1)
Local $hGraph = GUICtrlCreateGraphic(0, 0, $iWidth, $iHeight)
Local $sCol
For $i = 0 To $iHeight - 1
$sCol = StringFormat("0x%02X%02X%02X", $colorR + $StepR * $i, $colorG + $StepG * $i, $colorB + $StepB * $i)
GUICtrlSetGraphic(-1, 8, $sCol) ;$GUI_GR_COLOR = 8
GUICtrlSetGraphic(-1, 6, 0, $i) ;$GUI_GR_MOVE = 6
GUICtrlSetGraphic(-1, 2, $iWidth, $i) ;$GUI_GR_LINE = 2
Next
Return $hGraph
EndFunc ;==>_OwnTab_Gradient
Func _OwnTab_Style5($hWnd, $iX, $iY, $iWidth, $iHeight)
Local $rgn, $rgn2, $diameter = $iHeight
Local $hGui = GUICreate("OwnTab", $iWidth, $iHeight, $iX, $iY, 0x40000000, 0, $hWnd)
$rgn = _WinAPI_CreateRoundRectRgn($iWidth + 1, 0, 0, $iWidth, $diameter, $diameter)
_WinAPI_SetWindowRgn($hGui, $rgn)
GUISetState()
Return $hGui
EndFunc ;==>_OwnTab_Style5
Func startbmp($gui, $iWidth, $iHeight)
;Create a new bitmap, this way the original opened png is left unchanged
$hBitmap = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($gui))
$hImage = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hBitmap)
_WinAPI_DeleteObject($hBitmap)
Return $hImage
EndFunc ;==>startbmp
Func _drawborder($hBitmap, $gwt, $ght, $depth, $colour1, $colour2, $corner)
$iC1 = StringReplace($colour1, "0x", "0xFF")
$iC2 = StringReplace($colour2, "0x", "0xFF")
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hBrush = _GDIPlus_BrushCreateSolid($iC1)
Global $hBrush2 = _GDIPlus_BrushCreateSolid(0xFF7E3517)
Local $aFactors[4] = [0.0, 0.6, 0.8, 1.0], $aPositions[4] = [0.0, 0.6, 0.8, 1.0]
Local $bGammaCorrection = False
$hBrush1 = _GDIPlus_CreateLineBrushFromRect(0, 0, $gwt, $ght, $aFactors, $aPositions, "0xFFBBBBBB", $iC1, 1)
GDIPlus_SetLineGammaCorrection($hBrush1, $bGammaCorrection)
$hBrush3 = _GDIPlus_CreateLineBrushFromRect(0, 0, $gwt, $ght, $aFactors, $aPositions, $iC1, $iC2, 3)
GDIPlus_SetLineGammaCorrection($hBrush3, $bGammaCorrection)
; Global $hBrush1 = _GDIPlus_BrushCreateSolid($iC2)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4)
_GDIPlus_GraphicsDrawRoundRect($hGraphics, 0, 0, $gwt, $ght, $corner, $hBrush3)
_GDIPlus_GraphicsDrawRoundRect($hGraphics, $depth, $depth, $gwt - ($depth * 2) - 2, $ght - ($depth * 2) - 2, $corner, $hBrush1)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BrushDispose($hBrush1)
_GDIPlus_BrushDispose($hBrush2)
_GDIPlus_GraphicsDispose($hGraphics)
Return $hBitmap
EndFunc ;==>_drawborder
Func finalizectrl($controlID, $hImage)
$hWnd = GUICtrlGetHandle($controlID)
$hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", 0x0172, "int", 0, "int", $hbmp)
If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0])
_WinAPI_DeleteObject($hbmp)
EndFunc ;==>finalizectrl
;==== GDIPlus_CreateLineBrushFromRect === Malkey's function
Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
$iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)
Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount
[/autoit] [autoit][/autoit] [autoit]If $iArgb1 = Default Then $iArgb1 = 0xFF0000FF
If $iArgb2 = Default Then $iArgb2 = 0xFFFF0000
If $LinearGradientMode = -1 Or $LinearGradientMode = Default Then $LinearGradientMode = 0x00000001
If $WrapMode = -1 Or $LinearGradientMode = Default Then $WrapMode = 1
$tRect = DllStructCreate("float X;float Y;float Width;float Height")
$pRect = DllStructGetPtr($tRect)
DllStructSetData($tRect, "X", $iX)
DllStructSetData($tRect, "Y", $iY)
DllStructSetData($tRect, "Width", $iWidth)
DllStructSetData($tRect, "Height", $iHeight)
$aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _
"int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)
If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]
If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]
$iCount = UBound($aPositions)
$tFactors = DllStructCreate("float[" & $iCount & "]")
$pFactors = DllStructGetPtr($tFactors)
For $iI = 0 To $iCount - 1
DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)
Next
$tPositions = DllStructCreate("float[" & $iCount & "]")
$pPositions = DllStructGetPtr($tPositions)
For $iI = 0 To $iCount - 1
DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)
Next
$hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _
"ptr", $pFactors, "ptr", $pPositions, "int", $iCount)
Return $aRet[6] ; Handle of Line Brush
EndFunc ;==>_GDIPlus_CreateLineBrushFromRect
Func GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True)
Local $aResult
$aResult = DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", $useGammaCorrection)
Return $aResult[0]
EndFunc ;==>GDIPlus_SetLineGammaCorrection
Func _GDIPlus_GraphicsDrawRoundRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius, $hBrush = 0, $hPen = 0)
_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)
; _GDIPlus_GraphicsPathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90)
_GDIPlus_GraphicsPathAddLine($hPath, $iX + $iWidth, $iY + $iHeight, $iX, $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)
;Draw the font onto the new bitmap
_GDIPlus_GraphicsPathCloseFigure($hPath)
If $hBrush <> 0 Then _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hPath)
_GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hPath)
_GDIPlus_GraphicsPathDispose($hPath)
_GDIPlus_PenDispose($hPen)
EndFunc ;==>_GDIPlus_GraphicsDrawRoundRect
Func _GDIPlus_GraphicsPathCreate($iFillMode = 0)
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 ;==>_GDIPlus_GraphicsPathCreate
Func _GDIPlus_GraphicsPathAddLine($hGraphicsPath, $iX1, $iY1, $iX2, $iY2)
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 ;==>_GDIPlus_GraphicsPathAddLine
Func _GDIPlus_GraphicsPathAddArc($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle)
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 ;==>_GDIPlus_GraphicsPathAddArc
Func _GDIPlus_GraphicsPathCloseFigure($hGraphicsPath)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hGraphicsPath)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc ;==>_GDIPlus_GraphicsPathCloseFigure
Func _GDIPlus_GraphicsPathDispose($hGraphicsPath)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hGraphicsPath)
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aResult[0], 0, 0)
EndFunc ;==>_GDIPlus_GraphicsPathDispose
Func _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hGraphicsPath)
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 ;==>_GDIPlus_GraphicsDrawPath
Func _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hGraphicsPath)
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 ;==>_GDIPlus_GraphicsFillPath