  
 
[REQU] Patchou PlusWnd::Combo_GetItemText not exist why? - 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: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? (/showthread.php?tid=75710)
 
[REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by Flash on 06-28-2007 at 04:24 PM
... all words in the topic   
 
 
oh and thx for the search option in the script editor 
but u can add GOTO line option to plssssss?
  
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by deAd on 06-28-2007 at 04:30 PM
You can use the LB_GETLBTEXTLEN and LB_GETLBTEXT messages to get the text of a combo box item.
  
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by felipEx on 06-28-2007 at 06:59 PM
how about  
PlusWnd::LstBox_Clear( 
[string] ControlId 
); 
 
Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle(ControlId), 0x184 /* LB_RESETCONTENT */, 0, 0); 
 
 
  
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by Flash on 06-28-2007 at 07:44 PM
 quote: Originally posted by felipEx 
how about  
PlusWnd::LstBox_Clear( 
[string] ControlId 
); 
 
Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle(ControlId), 0x184 /* LB_RESETCONTENT */, 0, 0); 
 
 
  while mode  
while (ww.Combo_GetCount("cbc")){ 
        ww.Combo_RemoveItem("cbc",0); 
    }
 
RE: RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by felipEx on 06-28-2007 at 07:47 PM
 quote: Originally posted by Flash 
quote: Originally posted by felipEx 
how about  
PlusWnd::LstBox_Clear( 
[string] ControlId 
); 
 
Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle(ControlId), 0x184 /* LB_RESETCONTENT */, 0, 0); 
 
 
  while mode  
while (ww.Combo_GetCount("cbc")){ 
        ww.Combo_RemoveItem("cbc",0); 
    } 
  works fine too  but i like LB_RESETCONTENT, fast & short  
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by Flash on 06-28-2007 at 08:02 PM
your code not work on my combo, so 
i see the w.GetControlText("cbc") return selected text on the combo   good new 
-> 
The PlusWnd::GetControlText function returns the text property of a ButtonControl, a CheckBoxControl, a RadioControl, a LinkControl, an EditControl, a RichEditControl, a RichStaticControl or a StaticControl. 
 
 quote: Originally posted by felipEx 
works fine too  but i like LB_RESETCONTENT, fast & short  
   
 
but why u speak for reset the content is not my question man 
 
i need to know the text in each line of my combo  
 
RE: RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by felipEx on 06-28-2007 at 09:03 PM
 quote: Originally posted by Flash 
quote: Originally posted by felipEx 
works fine too  but i like LB_RESETCONTENT, fast & short  
   
 
but why u speak for reset the content is not my question man 
 
i need to know the text in each line of my combo   
  sure...  but you've suggested PlusWnd::Combo_GetItemText and i've suggested PlusWnd::LstBox_Clear   
 
 so...  it works fine here  
 
code: var CB_GETCOUNT = 0x146; 
var CB_GETLBTEXT = 0x148; 
var CB_GETLBTEXTLEN = 0x149; 
for (var i=0; i <  Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle("MyComboBox"), CB_GETCOUNT , 0, 0) ; i++)      { 
      var length = Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle("MyComboBox"), CB_GETLBTEXTLEN, i, 0); 
  var Data = Interop.Allocate((length * 2) + 2); 
  Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle("MyComboBox"), CB_GETLBTEXT, i, Data); 
      Debug.Trace(Data.ReadString(0)); 
      }
  
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by Flash on 06-28-2007 at 09:51 PM
i find this for combo = cb_ 
 code: function cb_ClrCtrl(w,d) { 
    //Interop.Call("user32", "SendMessageW", w.GetControlHandle , 0x14B /* CB_RESETCONTENT */, 0, 0); 
    w.SendControlMessage(d,0x14B /* CB_RESETCONTENT */, 0, 0) 
} 
  
 
RE: RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by felipEx on 06-28-2007 at 10:21 PM
 quote: Originally posted by Flash 
i find this for combo = cb_ 
code: function cb_ClrCtrl(w,d) { 
    //Interop.Call("user32", "SendMessageW", w.GetControlHandle , 0x14B /* CB_RESETCONTENT */, 0, 0); 
    w.SendControlMessage(d,0x14B /* CB_RESETCONTENT */, 0, 0) 
} 
  
   
you seem that you're working with dispatchers functions =) . why Patchou doesn't implement programming-based on prototypes ? ^^
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by Flash on 06-28-2007 at 10:23 PM
i tryed your code felip that work fine 
 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 , CB_GETLBTEXT, i, Data); 
            //w.SendControlMessage(d,CB_GETLBTEXT,i,Data) not work 
            return Data.ReadString(0) 
        } 
    } 
} 
   
quote: Originally posted by felipEx 
you seem that you're working with dispatchers functions =) . why Patchou doesn't implement programming-based on prototypes ? ^^
   
yes i dont know how for other way   
 
 
its possible this way code: cb_GetItem(ww,"cbc",0) -> ww.cb_GetItem("cbc",0)
  ??
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by CookieRevised on 06-29-2007 at 12:04 AM
 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 , 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 waycode: 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.
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by felipEx on 06-29-2007 at 12:20 AM
heheh Mr. CookieRevised   
i has this code: 
 
 code: function Combo_Text(PlusWnd, ControlId, Index){ 
    var CB_GETCOUNT = 0x146; 
    var CB_GETLBTEXT = 0x148; 
    var CB_GETLBTEXTLEN = 0x149; 
    var CB_GETCURSEL = 0x147; 
     
    if (!Index) Index = Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle(ControlId), CB_GETCURSEL, 0, 0); 
    if (Index < 0)    return ""; 
     
     
      var Data = Interop.Allocate((  Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle(ControlId), CB_GETLBTEXTLEN, Index, 0)  * 2) + 2); 
PlusWnd.GetControlHandle(ControlId), CB_GETLBTEXT, Index, Data); 
      return Data.ReadString(0); 
}
   
 
Edit.. Ohh..  you've posted before me   (Combo_GetItemText is better hehe , nice job ^^)
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by CookieRevised on 06-29-2007 at 12:39 AM
I think you mean: quote:
 code: Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle(ControlId), CB_GETLBTEXT, Index, Data);
  
  otherwise that code, as you showed it here, doesn't make any sense at all as it is missing a big part at the beginning... 
 
And... (when that part would have been there), your code: 
 
- will not return the proper text for the first item in the list because of if(!Index). This is not the proper way to handle an optional parameter. If Index is 0, to get the first item of the list, then (!Index) will be -1, aka True and thus the selected item will be returned instead of the first item in the list. 
To check if an optional parameter is used or not you need to do: if (typeof(myvariable) === 'undefined') 
 
- will go bananas when you give a too high index as a parameter because CB_GETLBTEXTLEN and other messages will return CB_ERR in that case and your datablock will have a bad length. 
 
- will go bananas when nothing is selected in the list and you request the selected item because the new Index will be CB_ERR in that case. 
 
 
 
If you use my snippets you wont have those problems and it would also be faster. 
Here is that last and shortest snippet again, but with the addition of the optional index so that you can get the current selected item also (=addition of the second line):code: function Combo_GetItemText(pPlusWnd, sControlId, nItemIdx) { 
        var hControl = pPlusWnd.GetControlHandle(sControlId); 
        if (typeof(nItemIdx) === 'undefined') nItemIdx = Interop.Call("User32", "SendMessageW", hControl, 0x147 /* CB_GETCURSEL */, 0, 0); 
        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); 
}
   
 
 
RE: [REQU] Patchou PlusWnd::Combo_GetItemText not exist why? by Flash on 06-29-2007 at 02:48 AM
good job cookie 
  
 |