By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Retrieve ListBox items

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.