471,330 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Getting\Setting EditItem from Combobox Using SendMessage

Hey,

I have a handle to a combobox in a different process, I want to:
1. Get the item with the X index
2. Be able to set the selected item to Y (index)

I know how to do it for Listview controls, and I'm sure its possible
for Combobox's as well,
Any ideas?

Thanks!

--sternr
Aug 21 '08 #1
1 6956
Well, thanks for all your relpies(!!#$#@%!)

Anyway, I got is sloved so I figured why not post for everyone...
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError =
false)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int
wParam, string lParam);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError =
false,EntryPoint="SendMessage")]
public static extern IntPtr SendRefMessage(IntPtr hWnd, uint Msg, int
wParam, StringBuilder lParam);

uint CB_GETLBTEXT = 0x0148;
uint CB_SETCURSEL = 0x014E;

public string GetComboItem(int index)
{
StringBuilder ssb = new StringBuilder(256, 256);
SendRefMessage(this.Handle, CB_GETLBTEXT, index, ssb);
return ssb.ToString();
}

public void SetComboItem(int index)
{
SendMessage(this.Handle, CB_SETCURSEL, index,"0");
}

Cheers!

--sternr
Aug 25 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by JSK | last post: by
1 post views Thread by J A via .NET 247 | last post: by
3 posts views Thread by Rob | last post: by
18 posts views Thread by Lars Netzel | last post: by
5 posts views Thread by michelqa | last post: by
3 posts views Thread by Crazy Cat | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.