• Hab zwar nicht nachgeschaut, obs schon so eine UDF gibt, aber hab auch mal eine geschrieben :)

    Sie ist noch im Anfangsstadium... Ich werde sie noch erweitern und verbessern.
    Und mit GDI+ bin ich noch nicht so gut dabei, also Rücksicht ;)

    Ich war auch bis jetzt noch zu faul ein Funktionsheader zu schreiben, in dem die Funktion erklärt wird. Ich liefere einfach erstmal ein Testscript mit :)

    UDF:

    Spoiler anzeigen
    [autoit]

    Global $SpoilerInfoStruct = DLLStructCreate("int hWnd; int Button; int X; int Y; int Width; int Height")
    Global $GDIInfoStruct = DLLStructCreate("int Graphic; int Brush; int Format; int Font; int Family")
    Global $sDataButtonState = 1
    Global $Spoilertext = ""

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

    Func _Spoiler_StartUp($hWnd)
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    AdlibRegister("__Redraw", 500)
    DLLStructSetData($GDIInfoStruct, 1, $hGraphic)
    EndFunc

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

    Func _Spoiler_Create($hWnd, $sText, $sFont, $iSize, $iX, $iY, $iWidth, $iHeight)
    GUIRegisterMsg(0x000F, "__Redraw")
    GUIRegisterMsg(0x0111, "__Handler")

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

    $hLabel = GUICtrlCreateLabel("Spoiler:", $iX, $iY)
    GUICtrlSetFont(-1, 8.5, 800)
    $aPos = ControlGetPos($hWnd, "", $hLabel)
    $hButtonSpoiler = GUICtrlCreateButton("hide", $iX + $aPos[2] + 2, $iY - ($aPos[3] / 5))
    GUICtrlSetFont(-1, 7.5)

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

    DLLStructSetData($SpoilerInfoStruct, 1, $hWnd)
    DLLStructSetData($SpoilerInfoStruct, 2, $hButtonSpoiler)
    DLLStructSetData($SpoilerInfoStruct, 3, $iX)
    DLLStructSetData($SpoilerInfoStruct, 4, $iY + $aPos[3])
    DLLStructSetData($SpoilerInfoStruct, 5, $iWidth)
    DLLStructSetData($SpoilerInfoStruct, 6, $iHeight)

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

    _GDIPlus_GraphicsDrawRect(DLLStructGetData($GDIInfoStruct, 1), _
    DLLStructGetData($SpoilerInfoStruct, 3), _
    DLLStructGetData($SpoilerInfoStruct, 4), _
    DLLStructGetData($SpoilerInfoStruct, 5), _
    DLLStructGetData($SpoilerInfoStruct, 6))

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

    $Spoilertext &= $sText

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

    $hGraphic = DLLStructGetData($GDIInfoStruct, 1)

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

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
    DLLStructSetData($GDIInfoStruct, 2, $hBrush)
    $hFormat = _GDIPlus_StringFormatCreate()
    DLLStructSetData($GDIInfoStruct, 3, $hFormat)
    $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    DLLStructSetData($GDIInfoStruct, 5, $hFamily)
    $hFont = _GDIPlus_FontCreate($hFamily, $iSize, 2)
    DLLStructSetData($GDIInfoStruct, 4, $hFont)
    __DrawString($Spoilertext)
    EndFunc

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

    Func _Spoiler_Shutdown()
    $SpoilerInfoStruct = 0
    $GDIInfoStruct = 0
    AdlibUnRegister("__Redraw")
    _GDIPlus_FontDispose(DllStructGetData($GDIInfoStruct, 4))
    _GDIPlus_FontFamilyDispose(DllStructGetData($GDIInfoStruct, 5))
    _GDIPlus_StringFormatDispose(DllStructGetData($GDIInfoStruct, 3))
    _GDIPlus_BrushDispose(DllStructGetData($GDIInfoStruct, 2))
    _GDIPlus_GraphicsDispose(DLLStructGetData($GDIInfoStruct, 1))
    _GDIPlus_Shutdown()
    EndFunc

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

    Func __Redraw()
    If $sDataButtonState = 1 Then
    _GDIPlus_GraphicsDrawRect(DLLStructGetData($GDIInfoStruct, 1), _
    DLLStructGetData($SpoilerInfoStruct, 3), _
    DLLStructGetData($SpoilerInfoStruct, 4), _
    DLLStructGetData($SpoilerInfoStruct, 5), _
    DLLStructGetData($SpoilerInfoStruct, 6))

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

    __DrawString($Spoilertext)
    EndIf
    EndFunc

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

    Func __Handler($hWnd, $nMsg, $wParam, $lParam)
    $hButton = GUICtrlGetHandle(DLLStructGetData($SpoilerInfoStruct, 2))
    If $lParam = $hButton Then
    __StateHandler()
    EndIf
    EndFunc

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

    Func __StateHandler()
    Switch $sDataButtonState
    Case 0
    GUICtrlSetData(DLLStructGetData($SpoilerInfoStruct, 2), "hide")
    __Redraw()
    AdlibRegister("__Redraw", 500)
    $sDataButtonState = 1
    Case 1
    GUICtrlSetData(DLLStructGetData($SpoilerInfoStruct, 2), "show")
    AdLibUnRegister("__Redraw")
    _WinAPI_RedrawWindow(DLLStructGetData($SpoilerInfoStruct, 1))
    $sDataButtonState = 0
    EndSwitch
    EndFunc

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

    Func __DrawString($sText)
    $tLayout = _GDIPlus_RectFCreate(DLLStructGetData($SpoilerInfoStruct, 3), _
    DLLStructGetData($SpoilerInfoStruct, 4), _
    DLLStructGetData($SpoilerInfoStruct, 5), _
    DLLStructGetData($SpoilerInfoStruct, 6))

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

    $aInfo = _GDIPlus_GraphicsMeasureString(DLLStructGetData($GDIInfoStruct, 1), $sText, DLLStructGetData($GDIInfoStruct, 4), $tLayout, DLLStructGetData($GDIInfoStruct, 3))
    _GDIPlus_GraphicsDrawStringEx(DLLStructGetData($GDIInfoStruct, 1), $sText, DLLStructGetData($GDIInfoStruct, 4), $aInfo[0], DLLStructGetData($GDIInfoStruct, 3), DLLStructGetData($GDIInfoStruct, 2))
    EndFunc

    [/autoit]


    Und hier das Testscript:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <SpoilerUDF.au3>

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

    $Form1 = GUICreate("Form1", 400, 400, 448, 225)
    GUISetState(@SW_SHOW)

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

    $StartUp = _Spoiler_StartUp($Form1)
    $Label1 = _Spoiler_Create($Form1, "Test", "Arial", 12, 50,50, 200, 200)

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

    Do
    Sleep(50)
    Until GUIGetMsg() = -3

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

    _Spoiler_Shutdown()

    [/autoit]


    Bugs dürfen genannt werden! :D
    Ich hoffe es gefällt euch :)

    MfG

  • Hallo.
    Deine UDF ist ziemlich cool.
    Du solltest den Inhalt des Spoilers aber nicht nur auf Text begrenzen.
    Funktionen wie _Spoiler_SetText, _Spoiler_SetImage usw. wären da eine möglichkeit.
    Mir ist zudem folgendes aufgefallen: Wenn man z.B. einen Button so platziert, dass er sich mit dem Spoiler
    überschneidet, kann man den Button durch den Spoiler anklicken.
    MfG. PrideRage

    Meine Projekte:
    ClipBoard Manager (beendet)
    Gutes ClipBoard Verwaltungs Programm mit nützlichen Funktionen.

    HTML Creator (beendet)
    Nützliches Tool um schnell ein eigenes HTML Dokument zu erstellen.