Jump to content

Recommended Posts

Posted

hi

i'm writing some programs with autoit and now i want to set some colors on my text to highlight them

i'm using GUICtrlCreateEdit() and write some text into the editbox with GUICtrlSetData()

and then i try to set color with GUICtrlSetColor() ... that's let me change the color text

....but it change all when i try to add some text new with GUICtrlSetData() and set color with GUICtrlSetColor() again

they didn't changed with the new color that i set...

can someone help me out

[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

Posted (edited)

hi

i'm writing some programs with autoit and now i want to set some colors on my text to highlight them

i'm using GUICtrlCreateEdit() and write some text into the editbox with GUICtrlSetData()

and then i try to set color with GUICtrlSetColor() ... that's let me change the color text

....but it change all when i try to add some text new with GUICtrlSetData() and set color with GUICtrlSetColor() again

they didn't changed with the new color that i set...

can someone help me out

I write an example:

$GUI = GUICreate("TEST",100,50)
$TEXT = GUICtrlCreateInput("This is a test",5,5,90,20)
GUICtrlSetColor($TEXT,0xFF0000)
$CHANGE = GUICtrlCreateButton("New Text",5,30,90,20)
GUISetState()

While 1
    $MSG = GUIGetMsg()
    If $MSG = $CHANGE Then
        GUICtrlSetData($TEXT,_RandomText(6))
    ElseIf $MSG = -3 Then
        Exit
    EndIf
    Sleep(20)
WEnd

Func _RandomText($NUM)
    $WORD = ""
    For $INDEX = 1 To $NUM
        $WORD &= Chr(Random(65,90,1))
    Next
    Return $WORD
EndFunc

The color isn't change for a new word.

And here color changed from every new word:

$GUI = GUICreate("TEST",100,50)
$TEXT = GUICtrlCreateInput("This is a test",5,5,90,20)
GUICtrlSetColor($TEXT,0xFF0000)
$CHANGE = GUICtrlCreateButton("New Text",5,30,90,20)
GUISetState()

While 1
    $MSG = GUIGetMsg()
    If $MSG = $CHANGE Then
        GUICtrlSetData($TEXT,_RandomText(6))
        GUICtrlSetColor($TEXT,"0x" & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2) & Hex(Random(0,255,1),2))
    ElseIf $MSG = -3 Then
        Exit
    EndIf
    Sleep(20)
WEnd

Func _RandomText($NUM)
    $WORD = ""
    For $INDEX = 1 To $NUM
        $WORD &= Chr(Random(65,90,1))
    Next
    Return $WORD
EndFunc
Edited by Andreik
Posted

Thank you Andreik for helping ^^

now i'm know more .....that editbox can only have one color is that right ???

it can't be hightlighted only some words because of changing color have effect of all words in the editbox

did i understand it right ?? ^^

[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

  • Moderators
Posted

Search the forum for "RichEdit". Especially in the example scripts forum.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Thank you Andreik for helping ^^

now i'm know more .....that editbox can only have one color is that right ???

it can't be hightlighted only some words because of changing color have effect of all words in the editbox

did i understand it right ?? ^^

Yes, you can have only one color but look here

Posted

Thank you Smoke_n and Andreik for help...

That's make me know there is a way to use more than one color...

...but dont get it really

....try to use some function from Lazycat RTF_writer it's hard to understand (for me)...

and don't get it to work... (already copied the rtf_writer to 'include' folder)

but thank's again for great support^^

[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...