468,513 Members | 1,712 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

Retrieve ListBox items

I am currently trying to retrieve a certain item in a listbox by
passing in the window handle and the string value of the item I am
looking for. I know that once I have the window handle of the listbox
I can retrieve the item where it matches the string value I passed in
to the method. Once I retrieve the correct item I want to be able to
highlight that item, but the problem is that I do not know the correct
syntax for this to happen. The code is not compiling correctly. If
someone could please help me out with this simple task I would
appreciate it.

void CListBoxTest::TestHighLight( HWnd hwnd, string value )
{
int itemValue = SendMessage( hwnd, LB_FINDSTRINGEXACT, -1, value );
//To add the code here for highlighting listbox item once the index
is found
}

Sep 15 '06 #1
2 3254
Kodiak wrote:
int itemValue = SendMessage( hwnd, LB_FINDSTRINGEXACT, -1, value );
value.c_str()

Even if your next question has a C++ answer, you will do much better to
learn more C++ before coding a hard library like the Win32 SDK, and you
ought to post your next question to a newsgroup with 'microsoft' in its
name.

This newsgroup is only qualified to discuss the raw C++ language itself, not
the minutia of all its libraries.

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Sep 15 '06 #2
Kodiak wrote:
I am currently trying to retrieve a certain item in a listbox by
passing in the window handle and the string value of the item I am
looking for. I know that once I have the window handle of the listbox
I can retrieve the item where it matches the string value I passed in
to the method. Once I retrieve the correct item I want to be able to
highlight that item, but the problem is that I do not know the correct
syntax for this to happen. The code is not compiling correctly. If
someone could please help me out with this simple task I would
appreciate it.

void CListBoxTest::TestHighLight( HWnd hwnd, string value )
{
int itemValue = SendMessage( hwnd, LB_FINDSTRINGEXACT, -1, value );
If 'string' is the part of the standard library, you probably need to
use 'c_str' member function to extract the pointer to char to pass to
your 'SendMessage'. Now, this is just a guess, and you can find out
for sure by posting to the newsgroup that knows about 'SendMessage'
function, like 'comp.os.ms-windows.programmer'.
>

//To add the code here for highlighting listbox item once the index
is found
}
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by 00_ChInkPoIntD12 | last post: by
3 posts views Thread by Ali Chambers | last post: by
4 posts views Thread by rn5a | last post: by
1 post views Thread by dudis3 | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.