bischen googlen hilft doch immer ...
aus nem forum:
PHP Code:
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Color.au3>
Main()
Func Main()
Local $hGui, $hRichEdit, $iMsg, $cButton
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "::::::::::::::DEMO::::::::::::::", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL,$ES_NOHIDESEL))
$cButton = GUICtrlCreateButton("Add", 20, 320, 100, 20)
GUISetState()
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
GUIDelete()
Exit
Case $iMsg = $cButton
_GUICtrlRichEdit_SetSel($hRichEdit,-1,-1) ; Cursor ans Ende setzen
_RichEdit_AddColoredText($hRichEdit,@CR & "This is some Text",_NewColor())
EndSelect
WEnd
EndFunc ;==>Main
Func _NewColor()
Local $aHex = StringSplit("0123456789ABCDEF", "", 2), $sRet = "0x"
For $i = 1 To 6
$sRet &= $aHex[Random(0, 15, 1)]
Next
Return $sRet
EndFunc ;==>_NewColor
Func _RichEdit_AddColoredText($hRichEdit, $sText, $nColor)
;SEuBo
Local $aSel, $aNSel
$aSel = _GUICtrlRichEdit_GetSel($hRichEdit) ; aktuelle Cursorpos.
_GUICtrlRichEdit_AppendText($hRichEdit, $sText) ; Text ahängen
$aNSel = _GUICtrlRichEdit_GetSel($hRichEdit) ; Cursorpos nach dem Text einfügen
_GUICtrlRichEdit_SetSel($hRichEdit, $aSel[0], $aNSel[0], True) ; Geschriebenen Text wählen
_GUICtrlRichEdit_SetCharColor($hRichEdit, $nColor) ; Einfärben
_GUICtrlRichEdit_SetSel($hRichEdit, -1, -1) ; Und cursor ans ende setzen
EndFunc ;==>_RichEdit_AddColoredText
machst du halt draus:
PHP Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>
#include <Color.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 345, 290, 192, 124)
$hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 40, 16, 273, 175, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL,$ES_NOHIDESEL))
$Input1 = GUICtrlCreateInput("[Account]", 40, 202, 121, 21)
$Input2 = GUICtrlCreateInput("mein text", 40, 232, 121, 21)
$Input3 = GUICtrlCreateInput("zusatz", 40, 262, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 192, 232, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_GUICtrlRichEdit_SetSel($hRichEdit,-1,-1)
_GUICtrlRichEdit_AppendText($hRichEdit,GUICtrlRead($Input1))
_RichEdit_AddColoredText($hRichEdit, GUICtrlRead($Input2), 0xFF0000)
_RichEdit_AddColoredText($hRichEdit,"|", 0x000000)
_RichEdit_AddColoredText($hRichEdit,GUICtrlRead($Input3), 0x00FF00)
_RichEdit_AddColoredText($hRichEdit, @CR, 0x000000)
EndSwitch
WEnd
Func _RichEdit_AddColoredText($hRichEdit, $sText, $nColor)
;SEuBo
Local $aSel, $aNSel
$aSel = _GUICtrlRichEdit_GetSel($hRichEdit) ; aktuelle Cursorpos.
_GUICtrlRichEdit_AppendText($hRichEdit, $sText) ; Text ahängen
$aNSel = _GUICtrlRichEdit_GetSel($hRichEdit) ; Cursorpos nach dem Text einfügen
_GUICtrlRichEdit_SetSel($hRichEdit, $aSel[0], $aNSel[0], True) ; Geschriebenen Text wählen
_GUICtrlRichEdit_SetCharColor($hRichEdit, $nColor) ; Einfärben
_GUICtrlRichEdit_SetSel($hRichEdit, -1, -1) ; Und cursor ans ende setzen
EndFunc ;==>_RichEdit_AddColoredText