What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with GetItemText

Help with GetItemText
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Help with GetItemText
Hey.

I'm making an website for quotes for my IRC channel. The idea is, that people can send in quotes, but I do of course not want everything quoted on the site, so my idea is to combine it with MSG Plus! When people have added a quote on the website, it shall be accepted or declined in MSG Plus!

My idea is to make a list control where all quotes appears and when I press the accept/decline button a webpage should popup where I'll run some PHP codes to update the MySQL database.

What I want is, that when you have chosen a quote on the list control and pressed the accept/decline button, I want to get the ID for the quote.
At the moment the ID shall only popup in a toast for further development.

I can't figure out how to get the ID.

Here's my code:

code:
function initializeWin()
{
    var LstQuotes = MsgPlus.CreateWnd("LstQuotes.xml", "Win");

    for(i=1;i<=5;i++)
    {
        var item = LstQuotes.LstView_AddItem("ListView", i);
        LstQuotes.LstView_SetItemText("ListView", item, 1, "Quote no. " + i);
    }
}

function OnWinEvent_CtrlClicked(Wnd, CtrlId)
{
    switch(CtrlId)
    {   
        case "BtnAccept":
        {
            MsgPlus.DisplayToast("WoWForge Quotes", "Test: " + LstQuotes.LstView_GetItemText("ListView", "DON'T KNOW WHAT VALUE I HAVE TO GIVE THIS", 0));
            break;
        }
    }
}

You can check the red line with the bolded text. Well, the text says it all. I think, I've made it right, but I don't know what value I have to put there.

The necessary part of my XML document:
code:
        <Control xsi:type="ListViewControl" Id="ListView">
            <Position Top="1" Width="350" Left="2" Height="100">
                <Anchor Horizontal="LeftRightFixed" Vertical="TopBottomFixed"/>
            </Position>
            <Attributes>
                <AutoTip>false</AutoTip>
                <AlwaysShowSelection>false</AlwaysShowSelection>
            </Attributes>

            <ReportView>
                <SortColHeader>true</SortColHeader>
            </ReportView>

            <Columns>
                <Column>
                    <ColumnId>No</ColumnId>
                    <Label>#</Label>
                    <Width>5</Width>
                </Column>
                <Column>
                    <ColumnId>Quote</ColumnId>
                    <Label>Quote</Label>
                    <Width>98</Width>
                </Column>
            </Columns>
        </Control>

                <Control xsi:type="ButtonControl" Id="BtnAccept">
                <Position Left="2" Top="104" Width="172" Height="15"/>
            <Caption>Accepter</Caption>
            </Control>

              <Control xsi:type="ButtonControl" Id="BtnDecline">
                     <Position Left="180" Top="104" Width="172" Height="15"/>
            <Caption>Afvis</Caption>
             </Control>

I've attached a picture, so it's easier for you to see, what I'm talking about. By ID, I mean the number in the #-row. That's what I want.

Thanks in advance
Simon Støvring

.gif File Attachment: lstview_quotes.gif (11.15 KB)
This file has been downloaded 120 time(s).
07-15-2008 01:08 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Help with GetItemText
You'll need to get the index of currently selected item in your ListView. Because ListViewControls support multi-selections (although you have to specify it in your XML to actually use this), you have to loop through all rows and see if that row is selected or not. If it is selected, you can use that index.

code:
//Loop from the first (index 0) to the last (index Count-1, Count is not included with the < operator) row in the list
for(var Index=0; Index < PlusWnd.LstView_GetCount("ListView"); Index++) {
   //If this item is selected...
   if(PlusWnd.LstView_GetSelectedState("ListView", Index) === true) {
      //Break out of the loop
      break;
   }
}
//Do something with Index, like
Debug.Trace("Selected item: "+PlusWnd.LstView_GetItemText("ListView", Index, 1));
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
07-15-2008 01:42 PM
Profile E-Mail PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Help with GetItemText
Yay! Many thanks ;-)

That's problably not the last word, you've heard from me... 8-)
07-15-2008 06:06 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On