Hier nur mal eine kleine Ansammlung von Funktionen die vielleicht dem Ein oder Anderen helfen könnten:
"Kästchenpapier"
#include-once
#include <GDIPlus.au3>
#comments-start
====================================================================================================
Name: GUICtrlMaths.au3
Author: James1337
====================================================================================================
#comments-end
Func _GUICtrlMaths_Startup()
Local $q = _GDIPlus_Startup()
SetError(@error, @extended)
Return $q
EndFunc
Func _GUICtrlMaths_Shutdown()
Local $q = _GDIPlus_Shutdown()
SetError(@error, @extended)
Return $q
EndFunc
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
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
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
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
Und hier noch ein Beispiel:
#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)
_GUICtrlMaths_SetText($Graphic, 'GUICtrlMaths\n \n © James1337\n \n \n 123 | $A\n+ 321 | +$B\n----- | ---\n 444 | $C', 0)
_GUICtrlMaths_Draw($Graphic)
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
String Funktionen
Func _StringLeft($String, $Left)
If StringLeft($String, StringLen($Left)) = $Left Then
Return True
Else
Return False
EndIf
EndFunc
Func _StringRight($String, $Right)
If StringRight($String, StringLen($Right)) = $Right Then
Return True
Else
Return False
EndIf
EndFunc
Func _StringTrimLeft($String, $Left)
If _StringLeft($String, $Left) Then
Return StringTrimLeft($String, StringLen($Left))
Else
SetError(1)
Return $String
EndIf
EndFunc
Func _StringTrimRight($String, $Right)
If _StringRight($String, $Right) Then
Return StringTrimRight($String, StringLen($Right))
Else
SetError(1)
Return $String
EndIf
EndFunc
MfG, James C.