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?
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);
}

;)

This post was edited on 06-29-2007 at 01:23 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-29-2007 12:39 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