Jump to content

Not setting image to correct item


Recommended Posts

What I'm trying to achieve is to be able to set a certain image depending on whether it reads a buddy as being online

or offline in the .ini file. My problem is below you can see I used $items in GUICtrlSetImage to be the controlID of the

currently being set item. Well it's setting an online image to ALL the items, not just the online.

_GUICtrlListView_DeleteAllItems($nListview); Deletes all items from the topmost listview
$varBuddies = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
$array = StringSplit($varBuddies, ";"); Splits the string up by using commas as delimiters
_ArrayDelete ( $array, 0 )
$readsection = IniReadSection("C:\buddies.ini", "OnlineBuddies"); Reads the online section
For $i = 0 To Ubound($array) - 1
    If $array[$i] <> "" Then $items = GUICtrlCreateListViewItem("|" & $array[$i], $nListview); Creates the listview items from the INI file
        If IsArray($readsection) Then
            For $z = 1 To $readsection[0][0]
                If $readsection[$z][0] = $array[$i] Then
                    $var0 = StringSplit($readsection[$z][1], "~"); splits by ~
                    $var1 = StringSplit($readsection[$z][1], ";"); splits by;
                    $date_ = StringTrimLeft($var1[UBound($var1)-1], 1)
                    $dateitems = _GUICtrlListView_SetItemText($nListview, $i, $date_, 2); Sets the date from the INI file
                Else
                EndIf
                If StringInStr($readsection[$z][1], "+On") Then; If the buddy is online
                    GUICtrlSetImage($items, "image.bmp"); Sets an online image
                Else
                    GUICtrlSetImage($items, "image1.bmp"); Sets an offline image
                EndIf
            Next
        EndIf
    Next
Edited by FireLordZi
While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

Look here to see what your doing wrong:

If StringInStr($readsection[$z][1], "+On") Then; If the buddy is online
                    GUICtrlSetImage($items, "image.bmp"); Sets an online image
                Else
                    GUICtrlSetImage($items, "image.bmp"); Sets an offline image
                EndIf

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Look here to see what your doing wrong:

If StringInStr($readsection[$z][1], "+On") Then; If the buddy is online
                    GUICtrlSetImage($items, "image.bmp"); Sets an online image
                Else
                    GUICtrlSetImage($items, "image.bmp"); Sets an offline image
                EndIfoÝ÷ Ûú®¢×ßÙj,,دxýz-²êi¢Ç¶Þ±ëmx"¶Ú4ߨ­zkɺËg¢ØyÒ0j˶ا+m¢Ø^±©f y»­¶­ßÛ'¢ÛazènW¦mçºÇ¢l¬r¸©¶Ø^ɪÞv'ßz·§¶)ë%G¬¡«­¢+Ø%MÑÉ¥¹%¹MÑÈ ÀÌØíÉÍÑ¥½¹lÀÌØíéulÅt°ÅÕ½Ðì­=¸ÅÕ½Ðì¤Q¡¸ì%Ñ¡Õä¥Ì½¹±¥¹(U%
ÑɱMÑ%µ ÀÌØí¥ÑµÌ°ÅÕ½Ðí¥µ¹µÀÅÕ½Ðì¤ìMÑ̸½¹±¥¹¥µ(±Í(U%
ÑɱMÑ%µ ÀÌØí¥ÑµÌ°ÅÕ½Ðí¥µÄ¹µÀÅÕ½Ðì¤ìMÑ̸½±¥¹¥µ(¹%
Edited by FireLordZi
While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

Give up with the AutoIt tags already!!

You're right. You shouldn't be setting it to $Items.

You also shouldn't be creating $Items the way you are. That is in a loop so that during every cycle of the loop you give a different value to $Items.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Give up with the AutoIt tags already!!

You're right. You shouldn't be setting it to $Items.

You also shouldn't be creating $Items the way you are. That is in a loop so that during every cycle of the loop you give a different value to $Items.

Well with all the screaming can you not suggest a possible solution?

I'm open to anything.

While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

Should I even be using $items? It is in a for loop so I understand that it's value will get changed everytime...BUT.

Before it's value gets changed it goes down to the GUICtrlSetImage() and sets the online or offline image depending on if that buddy is online? Why is this not working?

While Alive() {
	 DrinkWine();
}
AutoIt Programmer
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...