Eigenes Tab-Register (OwnTab-UDF)

  • Danke Raupi, hab den Link repariert.


    Schaut euch das mal an, was da ein Kanadier gebastelt hat:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <WinAPI.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Test OwnTab-Style 5", 640, 200)
    GUISetBkColor(0xFF080)

    [/autoit] [autoit][/autoit] [autoit]

    _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

    [/autoit] [autoit][/autoit] [autoit]

    _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)

    [/autoit] [autoit][/autoit] [autoit]

    _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)

    [/autoit] [autoit][/autoit] [autoit]

    GUISwitch($hGui)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Local $msg
    Do
    $msg = GUIGetMsg()
    If $msg > 0 Then MsgBox(0, "OwnTab", "You pressed tab with ID " & $msg & ".")
    Until $msg = -3

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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))

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_GraphicsDispose($hGraphics)
    Return $hBitmap
    EndFunc ;==>_drawborder

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    ;==== GDIPlus_CreateLineBrushFromRect === Malkey's function
    Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
    $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Func GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", $useGammaCorrection)
    Return $aResult[0]
    EndFunc ;==>GDIPlus_SetLineGammaCorrection

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    ;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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit]
  • Vielen Dank DjDominik.

    Bin gerade an einem größeren Umbau dabei, es werden sich bei dieser UDF noch einige Dinge ändern.

    Neue Graphik-Funktion zum Erstellen der Register
    [autoit]

    #Include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Overview OwnTab-Style 5", 840, 150)
    GUISetBkColor(0x0FF080)

    [/autoit] [autoit][/autoit] [autoit]

    $hTabGui = _OwnTab_Style5($hGui, 240, 60, 100, 65)
    $test = _OwnTab_Gradient5("0xaaaaaa","0x444444", 100, 65, 3)
    _OwnTab_Label("Graphic-Control", 100, 65)

    [/autoit] [autoit][/autoit] [autoit]

    $hTabGui2 = _OwnTab_Style5($hGui, 350, 60, 100, 65)
    $test2 = _OwnTab_Gradient5("0xffaaaa","0xff4444", 100, 65, 8)
    _OwnTab_Label("Graphic-Control", 100, 65)

    [/autoit] [autoit][/autoit] [autoit]

    $hTabGui3 = _OwnTab_Style5($hGui, 460, 60, 100, 65)
    $test3 = _OwnTab_Gradient5("0xffaa80","0x90aa00", 100, 65, 3)
    _OwnTab_Label("Graphic-Control", 100, 65)

    [/autoit] [autoit][/autoit] [autoit]

    GUISwitch($hGui)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Local $msg
    Do
    $msg = GUIGetMsg()
    If $msg > 0 Then MsgBox(0, "OwnTab", "You pressed tab with ID " & $msg & ".")
    Until $msg = -3

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Func _OwnTab_Gradient5($nStartColor, $nEndColor, $iWidth, $iHeight, $iBorder = 3)
    Local $hGraph[2]
    Local $colorR1 = Dec(StringLeft(Hex($nStartColor, 6), 2))
    Local $colorG1 = Dec(StringMid(Hex($nStartColor, 6), 3, 2))
    Local $colorB1 = Dec(StringMid(Hex($nStartColor, 6), 5, 2))
    Local $colorR2 = Dec(StringLeft(Hex($nEndColor, 6), 2))
    Local $colorG2 = Dec(StringMid(Hex($nEndColor, 6), 3, 2))
    Local $colorB2 = Dec(StringMid(Hex($nEndColor, 6), 5, 2))
    Local $StepR = ($colorR2 - $colorR1) / ($iHeight - 1)
    Local $StepG = ($colorG2 - $colorG1) / ($iHeight - 1)
    Local $StepB = ($colorB2 - $colorB1) / ($iHeight - 1)

    $hGraph[0] = GUICtrlCreateGraphic(0, 0, $iWidth, $iHeight)
    Local $sCol
    For $i = 0 To $iHeight - 1
    $sCol = StringFormat("0x%02X%02X%02X", $colorR2 - $StepR * $i, $colorG2 - $StepG * $i, $colorB2 - $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

    [/autoit] [autoit][/autoit] [autoit]

    $hGraph[1] = GUICtrlCreateGraphic(0, 0, $iWidth, $iHeight)
    Local $sCol, $iOff, $rad = ($iHeight / 2 - $iBorder)
    For $i = $iBorder To $iHeight / 2 - 1
    $iOff = $rad * (_sin(_ACos(($iHeight / 2 - $i)/$rad)))
    $sCol = StringFormat("0x%02X%02X%02X", $colorR1 + $StepR * $i, $colorG1 + $StepG * $i, $colorB1 + $StepB * $i)
    GUICtrlSetGraphic(-1, 8, $sCol) ;$GUI_GR_COLOR = 8
    GUICtrlSetGraphic(-1, 6, $iBorder + $rad - $iOff, $i) ;$GUI_GR_MOVE = 6
    GUICtrlSetGraphic(-1, 2, $iWidth - $rad - $iBorder + $iOff, $i) ;$GUI_GR_LINE = 2
    Next
    For $i = $iHeight / 2 To $iHeight - $iBorder - 1
    $sCol = StringFormat("0x%02X%02X%02X", $colorR1 + $StepR * $i, $colorG1 + $StepG * $i, $colorB1 + $StepB * $i)
    GUICtrlSetGraphic(-1, 8, $sCol) ;$GUI_GR_COLOR = 8
    GUICtrlSetGraphic(-1, 6, $iBorder, $i) ;$GUI_GR_MOVE = 6
    GUICtrlSetGraphic(-1, 2, $iWidth - $iBorder - 1, $i) ;$GUI_GR_LINE = 2
    Next
    Return $hGraph
    EndFunc ;==>_OwnTab_Gradient5

    [/autoit] [autoit][/autoit] [autoit]

    Func _Sin($fDegree)
    Local $pi = 3.14159265358979
    Local $degToRad = $pi / 180
    Return Sin($fDegree * $degToRad)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ACos($fValue)
    Local $pi = 3.14159265358979
    Local $radToDeg = 180 / $pi
    Return ACos($fValue) * $radToDeg
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Servus Funkey.

    Du solltest deine UDF mal auf die neue Autoitversion anpaßen. ;)

    Zeile 18

    [autoit]

    Opt("OnExitFunc", "_OwnTab_OnExit")

    [/autoit]


    in folgendes ändern:

    [autoit]

    OnAutoItExitRegister( "_OwnTab_OnExit")

    [/autoit]
  • Hallo Magnus,

    der Tab blinkt, weil dort eine wichtiges Ereignis (z.B. neue Info) eingetreten ist. Nachdem der Anwender auf das Tab gewechselt hat, hat er dieses ja gelesen, somit ist das Blinken überflüssig,

    mfg (Auto)Bert

  • Erstmal GENIAL die Funktion !!! Saubere Arbeit !!!

    Hab da ne kleine Frage zu: Wie erstellt man nachträglich Controls in den Tabs ??

  • Danke MrB!

    Nachträglich Controls hinzuzufügen funktioniert leider noch nicht. Hab aber im Moment (ich schätze mal das ganze restliche Jahr) noch keine Zeit mich wieder ernsthaft mit der OwnTab-UDF zu beschäftigen. Da wäre noch einiges zu fixen und zu ergänzen. Aber ich verspreche, dass ich diese Funktion noch hinzufügen werde.

  • Gibts es auch irgendwie eine Möglichkeit das per Koda zu machen?
    Ich bin nicht begabt ein Design per Code zu machen :(

  • Nein ausser funkey schreibt ein Koda plugin.

    Aber wo liegt denn dein Probem beim erstellen von Guis per Code?

    mfg Ubuntu

  • Die Positionen. Die kann man nur durch viel Glück und Rumprobieren rausfinden.
    Oder gibts da etwa einen Trick? ^^

  • Echt nice, aber ->

    Zitat

    D:\AutoIt3\Include\OwnTab.au3(18,35) : ERROR: Opt() called with illegal argument 1: "OnExitFunc"
    Opt("OnExitFunc", "_OwnTab_OnExit")


    *edit*
    Scheint aber nicht mit GuiOnEvent zu gehen, oder :(???

    Einmal editiert, zuletzt von Acanis (4. August 2010 um 20:35)

    • Offizieller Beitrag
    Zitat

    Echt nice, aber ->

    Zitat
    D:\AutoIt3\Include\OwnTab.au3(18,35) : ERROR: Opt() called with illegal argument 1: "OnExitFunc"
    Opt("OnExitFunc", "_OwnTab_OnExit")


    *edit*
    Scheint aber nicht mit GuiOnEvent zu gehen, oder :(???

    Das liegt an der Autoit Version, du mußt die neue Funktion in die UDF einfügen.

    Diese Zeile streichen:

    [autoit]

    Opt("OnExitFunc", "_OwnTab_OnExit")

    [/autoit]


    und durch diese ersetzen:

    [autoit]

    OnAutoItExitRegister( "_OwnTab_OnExit" )

    [/autoit]
  • Ja, wollte nur drauf aufmerksam machen ;D...

    Und halt fragen, ob sich das auch mit GuiOnEvent umsetzen lässt... -.- Die meisten Style-UDFs arbeiten mit GetMsg, so nervig xD... Das benutze ich nie xD...!

    Das Switchen habe ich nicht hin bekommen. Man kann ja nichts übergeben mit OnEvent und da die Controls keine "echten" sind, zünden die Makros auch nicht -.-...


    Will Tabs einfärben*argggghs*

    LG

  • Hallo Acanis,

    Und halt fragen, ob sich das auch mit GuiOnEvent umsetzen lässt...

    natürlich geht das. Hier das Original-Beispiel auf OnEvent umgeschrieben:

    Spoiler anzeigen
    [autoit]

    ; *** Start added by AutoIt3Wrapper ***
    #include <GUIConstantsEx.au3>
    ; *** End added by AutoIt3Wrapper ***
    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Add_Constants=n
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include "OwnTab.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1) ;ONEvent Mode.

    [/autoit] [autoit][/autoit] [autoit]

    Local $hGui = GUICreate("Funkey's OwnTab-UDF Example", 500, 350)
    GUISetBkColor(0xbbbbbb)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exitMain")
    $OwnTab_Style = Random(0, 1, 1) ;random style (only 2 styles available!!)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aTabText[5] = ["Settings", "Register without icon", "Pic", "Status", "Tab in Tab"] ;Declare the regions for the OwnTab-control
    Local $aTabIcons[5][2] = [["shell32.dll", 130],[""],["shell32.dll", 139],["shell32.dll", 90],["shell32.dll", 43]]
    Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 480, 300, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aTabTip[5] = ["Tip Item 1", "Tip Item 2", "Tip Item 3", "Alarm-Register"]
    _OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control

    [/autoit] [autoit][/autoit] [autoit]

    #region Tab1
    _OwnTab_Add($aCtrlTab) ;Start controls tab1
    Global $Edit1 = GUICtrlCreateEdit("Edit in Tab1", 20, 55, 300, 50, 0)
    GUICtrlCreateButton("Simulate an alarm", 20, 120, 300, 20)
    GUICtrlSetOnEvent(-1, "_AlarmSim")
    Global $Box1 = GUICtrlCreateCheckbox("Switch on hover - set time -->", 20, 180)
    GUICtrlSetOnEvent(-1, "_HoverTime")
    GUICtrlSetBkColor(-1, 0xCFE0E7)
    Global $Input1 = GUICtrlCreateInput("1", 200, 180, 50, 20)
    GUICtrlSetOnEvent(-1, "_HoverTime")
    GUICtrlCreateUpdown($Input1)
    GUICtrlSetLimit(-1, 15, 1)
    #endregion Tab1

    [/autoit] [autoit][/autoit] [autoit]

    #region Tab2
    _OwnTab_Add($aCtrlTab) ;Start controls tab2
    Global $Edit2 = GUICtrlCreateEdit("Edit in Tab2", 20, 150, 300, 50, 0)
    Global $Label2 = GUICtrlCreateLabel("Label in Tab2", 20, 220, 300, 20, 0x201)
    GUICtrlSetBkColor(-1, -2) ;$GUI_BKCOLOR_TRANSPARENT
    #endregion Tab2

    [/autoit] [autoit][/autoit] [autoit]

    #region Tab3
    _OwnTab_Add($aCtrlTab) ;Start controls tab3
    Global $Labe3 = GUICtrlCreateLabel("If you see this label, you can change the picture-path in scriptline " & @ScriptLineNumber + 1 & "!!", 40, 150, 400, 30, 0x201)
    Global $Edit3 = GUICtrlCreatePic(@DocumentsCommonDir & '\Eigene Bilder\Beispielbilder\Winter.jpg', 20, 55, 460, 280)
    #endregion Tab3

    [/autoit] [autoit][/autoit] [autoit]

    #region Tab4
    _OwnTab_Add($aCtrlTab) ;Start controls tab4
    GUICtrlCreateButton("Acknowledge the alarm", 20, 120, 300, 20)
    GUICtrlSetOnEvent(-1, "_AckAlarm")
    GUICtrlCreateButton("Enable tab 3", 20, 150, 300, 20)
    GUICtrlSetOnEvent(-1, "_EnableTab3")
    GUICtrlCreateButton("Disable tab 3", 20, 180, 300, 20)
    GUICtrlSetOnEvent(-1, "_DisableTab3")
    GUICtrlCreateButton("Hide tab 2", 20, 240, 300, 20)
    GUICtrlSetOnEvent(-1, "_HideTab2")
    GUICtrlCreateButton("Show tab 2", 20, 210, 300, 20)
    GUICtrlSetOnEvent(-1, "_ShowTab2")
    #endregion Tab4

    [/autoit] [autoit][/autoit] [autoit]

    #region Tab5 and "Tab in Tab"
    _OwnTab_Add($aCtrlTab) ;Start controls tab5

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Style Black", 30, 50, 200, 20, 0x201)
    $OwnTab_Style = 0
    Local $aTabText[2] = ["Tab1", "New Info"] ;Declare the regions for the OwnTab-control
    Local $aTabIcons[2][2] = [["C:\Programme\AutoIt3\Downloads\Seubo\head.ico"],["shell32.dll", 40]]
    Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText, 30, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons)
    _OwnTab_Add($aCtrlTab2) ;Start controls tab1
    GUICtrlCreateButton("Simulate", 80, 150, 100, 20)
    GUICtrlSetOnEvent(-1, "_Simulate")
    _OwnTab_Add($aCtrlTab2) ;Start controls tab2
    Global $BtnReset = GUICtrlCreateButton("Acknowledge", 80, 170, 100, 20)
    GUICtrlSetOnEvent(-1, "_Acknowledge")
    _OwnTab_End($aCtrlTab2)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Style White", 270, 50, 200, 20, 0x201)
    $OwnTab_Style = 1
    Local $aTabText[2] = ["Tab1", "Tab2"] ;Declare the regions for the OwnTab-control
    Local $aTabIcons[2][2] = [["shell32.dll", 10],["shell32.dll", 60]]
    Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText, 270, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons)
    _OwnTab_Add($aCtrlTab3) ;Start controls tab1
    GUICtrlCreateLabel("Just testing...", 280, 150, 100, 20)
    GUICtrlSetBkColor(-1, -2)
    _OwnTab_Add($aCtrlTab3) ;Start controls tab2
    GUICtrlCreateLabel("Hello from tab2", 280, 150, 100, 20)
    GUICtrlSetBkColor(-1, -2)
    _OwnTab_End($aCtrlTab3)
    #endregion Tab5 and "Tab in Tab"
    For $a = 1 To UBound($aCtrlTab, 1) - 1
    GUICtrlSetOnEvent($aCtrlTab[$a][0], "_OwnTab_OnEvent")
    Next
    For $a = 1 To UBound($aCtrlTab2, 1) - 1
    GUICtrlSetOnEvent($aCtrlTab2[$a][0], "_OwnTab_OnEvent")
    Next
    For $a = 1 To UBound($aCtrlTab3, 1) - 1
    GUICtrlSetOnEvent($aCtrlTab3[$a][0], "_OwnTab_OnEvent")
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab

    [/autoit] [autoit][/autoit] [autoit]

    _OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems
    _OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    _OwnTab_Hover($aCtrlTab, 0xFFFF88) ;start hover-function if you want. All GuiSetOnEvent-funcs must be defined before
    _OwnTab_AlarmInit()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $msg

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _exitMain()
    Exit
    EndFunc ;==>_exitMain

    [/autoit] [autoit][/autoit] [autoit]

    Func _OwnTab_OnEvent() ;for example
    ;ConsoleWrite(@GUI_CtrlId & @CRLF)
    For $a = 1 To UBound($aCtrlTab, 1) - 1
    If @GUI_CtrlId = $aCtrlTab[$a][0] Then ExitLoop
    Next
    If $a < UBound($aCtrlTab, 1) Then _OwnTab_Switch($aCtrlTab, $a)
    If $a = 5 Then
    _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1)
    _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1)
    EndIf
    For $a = 1 To UBound($aCtrlTab2, 1) - 1
    If @GUI_CtrlId = $aCtrlTab2[$a][0] Then ExitLoop
    Next
    If $a < UBound($aCtrlTab2, 1) Then _OwnTab_Switch($aCtrlTab2, $a)
    For $a = 1 To UBound($aCtrlTab3, 1) - 1
    If @GUI_CtrlId = $aCtrlTab3[$a][0] Then ExitLoop
    Next
    If $a < UBound($aCtrlTab3, 1) Then _OwnTab_Switch($aCtrlTab3, $a)
    EndFunc ;==>_OwnTab_OnEvent

    [/autoit] [autoit][/autoit] [autoit]

    Func _HoverTime()
    If GUICtrlRead($Box1) = 1 Then
    _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
    Else
    _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0)
    EndIf
    EndFunc ;==>_HoverTime

    [/autoit] [autoit][/autoit] [autoit]

    Func _EnableTab3()
    _OwnTab_Enable($aCtrlTab, 3)
    EndFunc ;==>_EnableTab3

    [/autoit] [autoit][/autoit] [autoit]

    Func _DisableTab3()
    _OwnTab_Disable($aCtrlTab, 3)
    EndFunc ;==>_DisableTab3

    [/autoit] [autoit][/autoit] [autoit]

    Func _HideTab2()
    _OwnTab_Hide($aCtrlTab, 2)
    EndFunc ;==>_HideTab2

    [/autoit] [autoit][/autoit] [autoit]

    Func _ShowTab2()
    _OwnTab_Show($aCtrlTab, 2)
    EndFunc ;==>_ShowTab2

    [/autoit] [autoit][/autoit] [autoit]

    Func _Simulate()
    _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF)
    EndFunc ;==>_Simulate

    [/autoit] [autoit][/autoit] [autoit]

    Func _Acknowledge()
    _OwnTab_ResetAlarm($aCtrlTab2, 2)
    EndFunc ;==>_Acknowledge

    [/autoit] [autoit][/autoit] [autoit]

    Func _AckAlarm()
    _OwnTab_ResetAlarm($aCtrlTab, 4)
    EndFunc ;==>_AckAlarm

    [/autoit] [autoit][/autoit] [autoit]

    Func _AlarmSim()
    _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000)
    EndFunc ;==>_AlarmSim

    [/autoit]

    Das Switchen habe ich nicht hin bekommen. Man kann ja nichts übergeben mit OnEvent und da die Controls keine "echten" sind, zünden die Makros auch nicht -.-...

    wieso @GUI_CtrlId funktioniert doch welche(s) Makro vermisst du denn?

    Beim Include-File den Hinweis von Raupi noch beachten!

    viel Spass im OnEvent-Modus beim Einfärben der TABS

    mfg (Auto)Bert

  • Geht doch? Muss ich nachher mal testen, arghs... xD

    Habe es nu anders gelöst, falls noch mal wer das ohne UDF lösen will xD... ->

    Die normale Tab-Funktion funktioniert auch, wenn man sie SUPER klein macht...
    Dann kann man ein Bild in der Hintergrundfarbe drüber legen und On Top setzen xD...

    Jetzt kann man die Tab-Befehle normal nutzen, ohne, dass man Tabs sieht!
    Zum aktivieren einfach ne Funktion erstellen, die dann einfach mit GUICtrlSetState() mit "SW_Show" (ich erkläre grade ausm Kopf, daher sorry xD...) das richtige "Tab" aktivieren^^...

    Was man vor der Tab-Funktion(also dem Start) schreibt, ist immer da, was man zwischen den Tab-Funktionen schreibt, funktioniert auch ohne Tab-Bereich wie ein Tab. Verschwindet und taucht wieder auf :p!

    Die Lösung mit der UDF ist natürlich eleganter, von daher schau ichs mir nachher noch mal an, danke AutoBert!!!

    Ich konnte das mit @GUI_CtrlId nicht umsetzen, gab bei mir immer 0 aus... Super gemacht :p!


    LG

  • Hi Funkey, wirklich gute Arbeit (auch wenn's schon eine Weile her ist)

    Schade :( das dein UDF keine TABs in mehreren Zeilen sondern nur in einer darstellen kann - oder habe ich da was übersehen?
    Gruß Dirgi