• Hier nur mal eine kleine Ansammlung von Funktionen die vielleicht dem Ein oder Anderen helfen könnten:

    "Kästchenpapier"
    [autoit]

    #include-once
    #include <GDIPlus.au3>

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

    #comments-start
    ====================================================================================================
    Name: GUICtrlMaths.au3
    Author: James1337
    ====================================================================================================
    #comments-end

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

    Func _GUICtrlMaths_Startup()
    Local $q = _GDIPlus_Startup()
    SetError(@error, @extended)
    Return $q
    EndFunc

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

    Func _GUICtrlMaths_Shutdown()
    Local $q = _GDIPlus_Shutdown()
    SetError(@error, @extended)
    Return $q
    EndFunc

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

    Func _GUICtrlMaths_Create($hWnd, $left, $top, $width, $height, $size=2)
    If $size < 1 Or $size > 8 Then
    SetError(1)
    Return 0
    EndIf
    Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    Local $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
    Local $buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    Local $controls[3] = [$graphics, $bitmap, $buffer]
    Local $position[4] = [$left, $top, $width, $height]
    Local $atext, $lines = Floor($height/(10+$size*5))
    Dim $atext[$lines]
    Local $maths[4] = [$controls, $position, $size, $atext]
    Return $maths
    EndFunc

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

    Func _GUICtrlMaths_Delete(ByRef $maths)
    $array1 = $maths[0]
    _GDIPlus_GraphicsDispose($array1[2])
    _GDIPlus_BitmapDispose($array1[1])
    _GDIPlus_GraphicsDispose($array1[0])
    $maths = 0
    Return True
    EndFunc

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

    Func _GUICtrlMaths_SetText(ByRef $maths, $text, $line=0)
    Local $position = $maths[1], $atext = $maths[3]
    If $line < 1 Then
    Local $_text, $lines = Floor($position[3]/(10+$maths[2]*5))
    Dim $_text[$lines]
    $atext = $_text
    $line = 1
    EndIf
    $atext[$line-1] = ''
    For $i = 1 To StringLen($text) Step 1
    If StringMid($text, $i, 1) = '\' Then
    If StringMid($text, $i+1, 1) = 'n' Then
    $line += 1
    If UBound($atext) < $line Then
    SetError(1)
    Return False
    EndIf
    $atext[$line-1] = ''
    $i += 1
    Else
    $atext[$line-1] &= StringMid($text, $i, 1)
    EndIf
    Else
    $atext[$line-1] &= StringMid($text, $i, 1)
    EndIf
    Next
    $maths[1] = $position
    $maths[3] = $atext
    Return True
    EndFunc

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

    Func _GUICtrlMaths_Draw(ByRef $maths)
    Local $controls = $maths[0], $position = $maths[1], $atext = $maths[3]
    _GDIPlus_GraphicsClear($controls[2], 0xFFFFFFFF)
    Local $size = 10+$maths[2]*5, $i
    For $i = 1 To Floor($position[2]/$size) Step 1
    _GDIPlus_GraphicsDrawLine($controls[2], $i*$size, 0, $i*$size, $position[3], 0)
    Next
    For $i = 1 To Floor($position[3]/$size) Step 1
    _GDIPlus_GraphicsDrawLine($controls[2], 0, $i*$size, $position[2], $i*$size, 0)
    Next
    $fsize = Floor($size*0.64)
    For $i = 0 To UBound($atext)-1 Step 1
    If $atext[$i] = '' Then
    ExitLoop
    EndIf
    For $j = 1 To StringLen($atext[$i]) Step 1
    Switch StringMid($atext[$i], $j, 1)
    Case ' ', @TAB, @CR, @LF
    ContinueLoop
    Case Else
    _GDIPlus_GraphicsDrawString($controls[2], StringMid($atext[$i], $j, 1), ($j-1)*$size+($size/$fsize)*2, $i*$size+($size/$fsize), 'Courier New', $fsize, 0x0020)
    EndSwitch
    Next
    Next
    _GDIPlus_GraphicsDrawImageRect($controls[0], $controls[1], $position[0], $position[1], $position[2], $position[3])
    $maths[0] = $controls
    $maths[1] = $position
    Return
    EndFunc

    [/autoit]


    Und hier noch ein Beispiel:

    [autoit]

    #include "GUICtrlMaths.au3"

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

    _GUICtrlMaths_Startup()

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

    $Gui = GUICreate('GUICtrlMaths by James1337', 400, 300)
    $Graphic = _GUICtrlMaths_Create($Gui, 15, 15, 370, 245)
    $Input = GUICtrlCreateInput('H\n e\n l\n l\n o\nWorld!', 20, 270, 200, 20)
    $Button = GUICtrlCreateButton('Draw', 240, 270, 100, 20)
    GUISetState(@SW_SHOW, $Gui)

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

    _GUICtrlMaths_SetText($Graphic, 'GUICtrlMaths\n \n © James1337\n \n \n 123 | $A\n+ 321 | +$B\n----- | ---\n 444 | $C', 0)
    _GUICtrlMaths_Draw($Graphic)

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

    Do
    $Msg = GUIGetMsg()
    If $Msg = $Button Then
    _GUICtrlMaths_SetText($Graphic, GUICtrlRead($Input), 0)
    _GUICtrlMaths_Draw($Graphic)
    EndIf
    Until $Msg = -3
    _GUICtrlMaths_Delete($Graphic)
    _GUICtrlMaths_Shutdown()
    Exit

    [/autoit]
    String Funktionen
    [autoit]

    Func _StringLeft($String, $Left)
    If StringLeft($String, StringLen($Left)) = $Left Then
    Return True
    Else
    Return False
    EndIf
    EndFunc

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

    Func _StringRight($String, $Right)
    If StringRight($String, StringLen($Right)) = $Right Then
    Return True
    Else
    Return False
    EndIf
    EndFunc

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

    Func _StringTrimLeft($String, $Left)
    If _StringLeft($String, $Left) Then
    Return StringTrimLeft($String, StringLen($Left))
    Else
    SetError(1)
    Return $String
    EndIf
    EndFunc

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

    Func _StringTrimRight($String, $Right)
    If _StringRight($String, $Right) Then
    Return StringTrimRight($String, StringLen($Right))
    Else
    SetError(1)
    Return $String
    EndIf
    EndFunc

    [/autoit]

    MfG, James C.

    AutoIt Version (Prod): 3.3.14.2

    AutoIt Version (Beta): 3.3.9.5

    ausgewählte Skripte: Chatbot, komplexe Zahlen (UDF)

    12 Mal editiert, zuletzt von James (5. August 2013 um 12:55)

  • Find ich ganz nützlich, besonders dsa Kästchenpapier.
    Test ich bei Gelegenheit mal :D - Wenn ich mal wieder Autoit statt C++ nutze :D

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal

  • Auch auf die Gefahr hin, dass das keinen interessiert:
    Hier mal die Farben, die ich in SciTE für AutoIt benutze:

    Spoiler anzeigen

    Ich weiß, es sieht anfangs etwas ungewöhnlich aus, aber lasst es am besten ersteinmal ein paar Minuten/Stunden auf euch wirken.

    MfG, James C.