Retrieve ListBox items

K

Kodiak

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
}
 
P

Phlip

Kodiak said:
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.
 
V

Victor Bazarov

Kodiak said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top