# How to change text color on a button with image?

## Recommended Posts

Hi!

I am writing some GUI and i need to use images as buttons, but with text on them (text is from INI file).

Part with button looks like this:

$ankieta1 = GUICtrlCreateButton($txtAnk1, 100,350,765,164)
GUICtrlSetFont(-1, 22, 800, -1, "Arial")
;GUICtrlSetColor(-1,0xffffff)
$hImageBtn_1 = _GUIImageList_Create(765, 164) _GUIImageList_AddBitmap($hImageBtn_1, "c:\path\to\ankieta_clean.bmp")
_GUICtrlButton_SetImageList($ankieta1,$hImageBtn_1, 4)
GUICtrlSetOnEvent(-1, "On_Ankieta1")

The problem - if i uncomment GUICtrlSetColor, color of text changes, but button is just plain gray (no image). How i can change text color not touching image on a button here?

##### Share on other sites

It's been a while but I don't think you can change the text of buttons that use a bitmap. You can add text to the bitmap before you set it to the button, like UEZ does in this topic

## Create an account

Register a new account

• ### Similar Content

• hello evrybody
here is an example about how to split your texts using a delimiter with the ability to select how much of delimiters shows in each colum  with $i_number e.g you have a long text and you want to split it in an array that evry colum have a number (n) of lines i made a function that do that for you just call it with a three params$s_text
$i_number the number that you want to put in each col$s_siparator
the siparator
default is "|"
here is the function with example
i hope that it will be useful for you

****

#include <Array.au3> $s_txt = "some text1some text2|some text3|some text4|some text5|some text6"$array = splitText($s_txt, 2) _ArrayDisplay($array) Func splitText($s_text,$i_number, $s_siparator = "|") Local$a_TXT = StringSplit($s_text,$s_siparator) Local $a_Return[$a_TXT[0] + 1] If ($a_TXT[0] <=$i_number) Or ($i_number <= 0) Then ReDim$a_Return[2] $a_Return[0] = 1$a_Return[1] = $s_text Return$a_Return EndIf Local $i_Processed = 1,$i_arrayProcessed = 1 Do For $i =$i_Processed To ($i_Processed +$i_number) - 1 If ($a_TXT[0] <$i) Then ExitLoop If Not ($a_Return[$i_arrayProcessed]) Then $a_Return[$i_arrayProcessed] = $a_TXT[$i] Else $a_Return[$i_arrayProcessed] &= $s_siparator &$a_TXT[$i] EndIf$i_Processed += 1 Next $i_arrayProcessed += 1 Until ($a_TXT[0] < $i_Processed) ReDim$a_Return[$i_arrayProcessed]$a_Return[0] = $i_arrayProcessed - 1 Return$a_Return EndFunc ;==>splitText
accept my greetings
thanks to
@Dan_555
for his notes

• Hello everyone,
Im developing an script to check the size of all .jpg stored in windows folder.
The problem is that it doesn´t work properly with rotated images.
With _GDIPlus_ImageGetWidth() and _GDIPlus_ImageGetHeight()  I get the Width and Height of images as if they had not been rotated, and I need to know how they are rotated (orientation and grades).

• hello autoit team
please i've a question for you.
am creating a audio player
and in this audio player i want to show the current trac info
such as the total time and the position ... etc
i know i can show it as label
but the screen reader for the blind read the text every change
because it have a screen scan
what i want is to show this informations but such image or icon
i mean i need to create
GUICtrlCreatepic or GUICtrlCreateicon ....
or some thing as that
and show this informations as image on it
i think that i can do that with the
_GDIPlus functions
but i couldn't find the currect way to do it
i tried the _GDIPlus_GraphicsDrawString
but i couldn't know how it work
what i need is a small example that create a GUI
and add a multy line text to it as graphic or image.
so i need a simple way because it will changed every sec
i hope any one can help me to do that
global $GUI = GUICreate("text", 400, 400) global$label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380) GUISetState() do sleep(100) until GUIGetMSG() = -3 exit func GetText() return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50") endFunc
• By therks
So I don't have any code cooked up yet as this is still in the theoretical stage. Just looking for some advice.
My current idea is to resize the image to 1x1 pixel, probably using _GDIPlus_ImageResize, and read the color of the resulting pixel to obtain an admittedly very general sense of brightness. Does anyone think this could work?
We have a CCTV system running at home using some home made cameras (raspberry pi) and we're trying to automate toggling settings for day/night time. We started with an AutoIt script that checked sunrise and sundown times for our location (calculations pulled from here) and toggled the settings based on that. Unfortunately our weather varies wildly, so it can get light/dark far outside normal sunrise/sundown times. Now we're hoping to periodically grab a still from the camera and toggle the light mode based on that.
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...