What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [REQU] Patchou PlusWnd::Combo_GetItemText not exist why?

[REQU] Patchou PlusWnd::Combo_GetItemText not exist why?
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why?
code:
function cb_GetItem(w,d,n){
        var CB_GETCOUNT = 0x146
        var CB_GETLBTEXT = 0x148
        var CB_GETLBTEXTLEN = 0x149
        var t = w.SendControlMessage(d,CB_GETCOUNT, 0, 0)
        //Debug.Trace("Total= " +t)
        for(var i=0; i < t; i++) {
                var length = w.SendControlMessage(d, CB_GETLBTEXTLEN, i, 0)
                var Data = Interop.Allocate((length * 2) + 2)
                if (i == n) {
                        Interop.Call("user32", "SendMessageW", w.GetControlHandle(d), CB_GETLBTEXT, i, Data);
                        //w.SendControlMessage(d,CB_GETLBTEXT,i,Data) not work
                        return Data.ReadString(0)
                }
        }
}
- You don't need the loop.
- Inside the loop you don't need to check if the index is the same as the parameter
- w.SendControlMessage(d,CB_GETLBTEXT,i,Data) does not work because you need to give a pointer to the Data object, not the object itself: w.SendControlMessage(d,CB_GETLBTEXT,i,Data.DataPtr)

The above code can be done way shorter and much faster:
code:
function Combo_GetItemText2(pPlusWnd, sControlId, nItemIdx) {
        if (nItemIdx >= 0 && nItemIdx <= pPlusWnd.Combo_GetCount(sControlId)) {
                var nLength = pPlusWnd.SendControlMessage(sControlId, 0x149 /* CB_GETLBTEXTLEN */, nItemIdx, 0);
                var Buffer = Interop.Allocate(nLength * 2 + 2);
                pPlusWnd.SendControlMessage(sControlId, 0x148 /* CB_GETLBTEXT */, nItemIdx, Buffer.DataPtr);
                return Buffer.ReadString(0)
        } else {
                return ''
        }
}
And this can be made even more shorter and faster:
code:
function Combo_GetItemText(pPlusWnd, sControlId, nItemIdx) {
        var hControl = pPlusWnd.GetControlHandle(sControlId);
        var nLength = Interop.Call("User32", "SendMessageW", hControl, 0x149 /* CB_GETLBTEXTLEN */, nItemIdx, 0);
        var Buffer = Interop.Allocate(nLength * 2 + 3);
        Interop.Call("User32", "SendMessageW", hControl, 0x148 /* CB_GETLBTEXT */, nItemIdx, Buffer.DataPtr);
        return Buffer.ReadString(0);
}


quote:
Originally posted by Flash
its possible this way
code:
cb_GetItem(ww,"cbc",0) -> ww.cb_GetItem("cbc",0)
??
no


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

PS: please do not make double posts. Double posting is posting more than once in a short time while nobody else made a reply. Read the forum rules.

This post was edited on 06-29-2007 at 12:06 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-29-2007 12:04 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by Flash on 06-28-2007 at 04:24 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by deAd on 06-28-2007 at 04:30 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by felipEx on 06-28-2007 at 06:59 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by Flash on 06-28-2007 at 07:44 PM
RE: RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by felipEx on 06-28-2007 at 07:47 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by Flash on 06-28-2007 at 08:02 PM
RE: RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by felipEx on 06-28-2007 at 09:03 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by Flash on 06-28-2007 at 09:51 PM
RE: RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by felipEx on 06-28-2007 at 10:21 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by Flash on 06-28-2007 at 10:23 PM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by CookieRevised on 06-29-2007 at 12:04 AM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by felipEx on 06-29-2007 at 12:20 AM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by CookieRevised on 06-29-2007 at 12:39 AM
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - by Flash on 06-29-2007 at 02:48 AM


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