Jump to content

Color specific parts in a label using guictrlsetdata?


Recommended Posts

What I am trying to do is pull some information (prices of items) off a page, save them to an .ini file, then use the logged info to display various things about the prices. I've gotten it to work, but now I'm trying to add some features just to make it easier to read and things of that type.

Here is my current code that eventually uses the $toset/$toset2 variables to display the information in two different labels on the GUI.

For $i = 0 to UBound($fullarray)-1
    if mod($i, 2) == 0 OR $i == 0 Then
        $toset = $toset&$fullarray[$i]&" : "&formattomoney(getavgprice($fullarray[$i]))&" --- "&formattomoney(getlastprice($fullarray[$i]))&" --- "&Round((getlastprice($fullarray[$i])/getavgprice($fullarray[$i]))*100,2)&"%"&@CR&@CR
    else
        $toset2 = $toset2&$fullarray[$i]&" : "&formattomoney(getavgprice($fullarray[$i]))&" --- "&formattomoney(getlastprice($fullarray[$i]))&" --- "&Round((getlastprice($fullarray[$i])/getavgprice($fullarray[$i]))*100,2)&"%"&@CR&@CR
    EndIf
Next

Later down the line

GUICtrlSetData($CONavglogp, $toset)
GUICtrlSetData($CONavglogp2, $toset2)

I want to know if there is a way to say If the percentage ( Round((getlastprice($fullarray[$i])/getavgprice($fullarray[$i]))*100,2)&"%" ) is less than 80%, then color that line, the name of the item, the average price, the percentage, and the current price, red or some other color.

Link to comment
Share on other sites

If ...percentage ... <80 Then

GuiCtrlSetBkColor(YourLabel,color)

Else

GuiCtrlSetBkColor(YourLabel,other_color)

EndIf

That's all fine and good when you are trying to change the whole string to a certain color, but since since I'm using Guictrlsetdata to update the items, and i dont want the whole thing to act as if were under 80%, that doesnt work.

Link to comment
Share on other sites

I'm not sure you can apply color to only "parts" of a label. Why not use labels for every element?

Your code doesn't show anything about how your GUI is supposed to be; try to make a simple example or post a screenshot in order to be able to get more detailed help.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

I'm not sure you can apply color to only "parts" of a label. Why not use labels for every element?

Your code doesn't show anything about how your GUI is supposed to be; try to make a simple example or post a screenshot in order to be able to get more detailed help.

It's ok. I decided away from labels and just used a ListView, it works much better. Thanks for your help though.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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