Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Get the list from from iexplorer combo box

Reply
Thread Tools

Get the list from from iexplorer combo box

 
 
ME
Guest
Posts: n/a
 
      04-10-2006
I need to be able to get the list from a combobox using PInvoke. This code
works fine for a windows form application however I need to read the
combobox that is on an HTML page (inside iexplorer, the class name for the
box is "Internet Explorer_TridentCmboBx" ). When I read the combobox from
IE it will accurately get the count, but the text of each item returns non
printable ascii characters.

What am I doing wrong?

Thanks,

Matt

//C#


//------------------------------ CODE ---------------------

public const UInt32 CB_GETCOUNT = 0x0146;
public const UInt32 CB_GETCURSEL = 0x0147;
public const UInt32 CB_GETLBTEXT = 0x0148;
public const UInt32 CB_GETLBTEXTLEN = 0x0149;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam,
IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam,
StringBuilder lParam);

public static List<ListItemVals> GetListItems(IntPtr controlPointer, object
sender)
{
int count = 0;
List<ListItemVals> retVal = new List<ListItemVals>();
ListItemVals item = new ListItemVals();
IntPtr zero = new IntPtr(0);
//Get the count of items in the list
IntPtr ptr = SendMessage(GetHandleRef(controlPointer, sender), CB_GETCOUNT,
zero, zero);
count = ptr.ToInt32();
for (int i = 0; i < count; i++)
{
item = GetValueFromCombo(controlPointer, sender, i);
retVal.Add(item);
}
return retVal;
}
public static ListItemVals GetValueFromCombo(IntPtr pointer, object sender,
int index)
{
//List<ListItemVals> retVal = new List<ListItemVals>();
int len = 0;
StringBuilder sb = new StringBuilder();
ListItemVals item = new ListItemVals();
IntPtr wParam = new IntPtr(index);
IntPtr zero = new IntPtr(0);
//Get the count of items in the list
IntPtr ptr = SendMessage(GetHandleRef(pointer, sender), CB_GETLBTEXTLEN ,
wParam, zero);
len = ptr.ToInt32();
sb.Capacity = len;
IntPtr txtPtr = SendMessage(GetHandleRef(pointer, sender), CB_GETLBTEXT,
wParam, sb);
//Get the list item
item.textValue = sb.ToString();
item.itemValue = wParam.ToInt32();

//return the value
return item;
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reference one combo box from another combo box SM Javascript 2 04-28-2007 04:49 PM
Fill Combo Box based on another Combo Box dthmtlgod ASP General 1 11-16-2005 04:08 PM
COMBO BOX INSTEAD OF DROP DOWN BOX =?Utf-8?B?QW5nZWw=?= ASP .Net 3 06-29-2004 06:38 PM
Populate List Box base on Combo Box Selection Adrian ASP General 1 02-18-2004 09:49 AM
Combo Box and text box Mike Javascript 2 09-24-2003 07:40 PM



Advertisments