472,952 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 3536
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now,...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
7
by: 00_ChInkPoIntD12 | last post by:
Can anyone confirm there isn't a Sort() method for WebControl Listbox in Asp.net? It is rather simple to write a method to do the sorting, but just wondering I shouldn't invent the wheel if...
2
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: -------------------------------...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
4
by: rn5a | last post by:
Can the items in a ListBox be sorted by the name of the items? The ListBox actually lists all directories & files existing in a directory on the server. Note that all the directories should be...
1
by: dudis3 | last post by:
Hello, I have this problem, I have populated a multiselect ListBox, but now I need to retrieve selected values, and use them as a parameters on the url e.g...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.