Shoutbox

List box clearing? - 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: List box clearing? (/showthread.php?tid=84813)

List box clearing? by SmokingCookie on 07-13-2008 at 08:55 PM

Hi,

Is there some WM_(X)-message that clears a ListBoxControl entirely?

I have tried this piece of code, without success:

code:
        for(i = 0; i <= PlusWnd.LstBox_GetCount("bLstFolders"); i++) {
            PlusWnd.LstBox_RemoveItem("bLstFiles",i);
        }


RE: List box clearing? by foaly on 07-13-2008 at 09:00 PM

try:

code:
while(wnd.LstBox_GetCount("list")>0){
        wnd.LstBox_RemoveItem("list",0);
    }


RE: List box clearing? by SmokingCookie on 07-13-2008 at 09:05 PM

Has anybody told you that you were clever? :P

Works, tnx :D


RE: List box clearing? by TheSteve on 07-14-2008 at 01:01 AM

I'm not sure if the MsgPlus list box is implemented with the windows list box or not, but if it is, sending the LB_RESETCONTENT message should immediately empty it.


RE: RE: List box clearing? by SmokingCookie on 07-14-2008 at 04:54 PM

That does it :D

Thanks :D

-----------------------------------

quote:
Originally posted by foaly
try:

code:
while(wnd.LstBox_GetCount("list")>0){
        wnd.LstBox_RemoveItem("list",0);
    }



I've tried this trick on a ListBoxControl and it seemed to work. On a ListViewControl, however, it crashes Messenger.. Is there any reason or solution to this problem?

code:
    while(WndSkinEditor.LstView_GetCount("vLstElementsLeft") >= 0) {
        WndSkinEditor.LstView_RemoveItem("vLstElementsLeft",0);
    }
    Debug.Trace("> Clearing \" vLstElementsRight\"");
    while(WndSkinEditor.LstView_GetCount("vLstElementsRight") >= 0) {
        WndSkinEditor.LstView_RemoveItem("vLstElementsRight",0);
    }

RE: List box clearing? by Matti on 07-14-2008 at 05:01 PM

It's much better to use the Win32 control messages for this, as if you make a mistake in your while-loop, you'll end up in an endless loop of doom and thus crashing your Messenger.

For list boxes:

code:
PlusWnd.SendControlMessage("ListBox", /* LB_RESETCONTENT */ 0x184, 0, 0);
For list views:
code:
PlusWnd.SendControlMessage("ListView", /* LVM_DELETEALLITEMS */ 0x1009, 0, 0);
The worst thing you can get then is a "bad calling convention" or something in your Interop.GetLastError(). :P

Blah, you already solved it yourself. Anyway, this post is for future generations. :P
RE: List box clearing? by SmokingCookie on 07-14-2008 at 05:05 PM

Yeah, excuses hea :P

Anyway, thanks for the solution (and for CDL 2.1 :D )