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
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 = ""
Func _Spoiler_StartUp($hWnd)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
AdlibRegister("__Redraw", 500)
DLLStructSetData($GDIInfoStruct, 1, $hGraphic)
EndFunc
Func _Spoiler_Create($hWnd, $sText, $sFont, $iSize, $iX, $iY, $iWidth, $iHeight)
GUIRegisterMsg(0x000F, "__Redraw")
GUIRegisterMsg(0x0111, "__Handler")
$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)
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)
_GDIPlus_GraphicsDrawRect(DLLStructGetData($GDIInfoStruct, 1), _
DLLStructGetData($SpoilerInfoStruct, 3), _
DLLStructGetData($SpoilerInfoStruct, 4), _
DLLStructGetData($SpoilerInfoStruct, 5), _
DLLStructGetData($SpoilerInfoStruct, 6))
$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
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
Func __Redraw()
If $sDataButtonState = 1 Then
_GDIPlus_GraphicsDrawRect(DLLStructGetData($GDIInfoStruct, 1), _
DLLStructGetData($SpoilerInfoStruct, 3), _
DLLStructGetData($SpoilerInfoStruct, 4), _
DLLStructGetData($SpoilerInfoStruct, 5), _
DLLStructGetData($SpoilerInfoStruct, 6))
__DrawString($Spoilertext)
EndIf
EndFunc
Func __Handler($hWnd, $nMsg, $wParam, $lParam)
$hButton = GUICtrlGetHandle(DLLStructGetData($SpoilerInfoStruct, 2))
If $lParam = $hButton Then
__StateHandler()
EndIf
EndFunc
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
Func __DrawString($sText)
$tLayout = _GDIPlus_RectFCreate(DLLStructGetData($SpoilerInfoStruct, 3), _
DLLStructGetData($SpoilerInfoStruct, 4), _
DLLStructGetData($SpoilerInfoStruct, 5), _
DLLStructGetData($SpoilerInfoStruct, 6))
$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
Und hier das Testscript:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <SpoilerUDF.au3>
$Form1 = GUICreate("Form1", 400, 400, 448, 225)
GUISetState(@SW_SHOW)
$StartUp = _Spoiler_StartUp($Form1)
$Label1 = _Spoiler_Create($Form1, "Test", "Arial", 12, 50,50, 200, 200)
Do
Sleep(50)
Until GUIGetMsg() = -3
_Spoiler_Shutdown()
[/autoit]Bugs dürfen genannt werden! ![]()
Ich hoffe es gefällt euch ![]()
MfG