Shoutbox

[?] LstView_SetItemText not working - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] LstView_SetItemText not working (/showthread.php?tid=77607)

[?] LstView_SetItemText not working by Spunky on 09-19-2007 at 07:27 PM

The code (below) doesn't seem to be working right. I'm making a list of all my contacts and then trying to read nicknames from the registry and set them in the next column. Adding the contact works fine, but it won't set the nickname text. I've checked the value of nickname and it is correct, it's just the function failing for some reason (Only reason in documentation is that the window may have already closed, but it hasn't)

Please help, it's driving me mad :(

code:
for (var objSubKey in objSubKeys){
                    nickname = Registry_GetKeyValue(HKCU, 'Software\\Patchou\\Messenger Plus! Live\\GlobalSettings\\Scripts\\myScript\\Settings\\'+Messenger.MyUserId+"\\"+objSubKey, "Nickname")
                    nick.LstView_AddItem("Contacts", findEmail(objSubKey), 0, nick.LstView_GetCount("Contacts"));
                    nick.LstView_SetItemText("Contacts", nick.LstView_GetCount("Contacts"), 0, nickname);
        }

RE: [?] LstView_SetItemText not working by markee on 09-20-2007 at 12:29 AM

You are trying to set the text of the next on in the list which doesn't exist yet.  After you use LstView_AddItem, in the next line the LstView_GetCount is increased by 1 and therefore doen't have the same index.  You can either minus one off of that in the SetItemText line, or you can just use the return value of the AddItem line and you should be fine.

Edit: also you don't need those last 2 parameters in the AddItem line as it will be added to the end of the list anyway and your itemData doesn't have any real purpose.


RE: [?] LstView_SetItemText not working by Spunky on 09-20-2007 at 12:35 AM

Minus 1 didn't work for some reason... Only about 5 or 6 contacts out of the list came up with the name... It's strange that they did when others didn't though. Using the returned index worked like a treat though :D Thanks. I couldn't understand because I've done this before somewhere.

"I may be an idiot, but there is one thing I'm not sir and that sir, is an idiot" :p


RE: [?] LstView_SetItemText not working by markee on 09-20-2007 at 11:47 AM

quote:
Originally posted by SpunkyLoveMuff
"I may be an idiot, but there is one thing I'm not sir and that sir, is an idiot"
OMG, I just watched that episode of family guy like 5 minutes ago.

Anyway, I'm glad that I could help you.
RE: [?] LstView_SetItemText not working by Matti on 09-20-2007 at 04:10 PM

LstView_AddItem returns the index of the added item. Use it!!!

code:
var Index = nick.LstView_AddItem(...);
nick.LstView_SetItemText(..., Index, ..., ...);

RE: [?] LstView_SetItemText not working by Spunky on 09-20-2007 at 04:42 PM

quote:
Originally posted by Mattike
LstView_AddItem returns the index of the added item. Use it!!!
code:
var Index = nick.LstView_AddItem(...);
nick.LstView_SetItemText(..., Index, ..., ...);


Thats exactly what I did ;)