Solved

Hoe do I Re-Highlight selected Items In a Multi-Select listBox

Posted on 2003-11-19
5
336 Views
Last Modified: 2011-10-03
After selecting Items in a MultiSelect list Box the Highligth is removed when I Click outside the List.
For example selecting a Radio button.

How to I reset the Highlight. I still have the Index of the selected Items.
0
Comment
Question by:MCofer
  • 3
5 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9781512
LB_SETSEL
An application sends an LB_SETSEL message to select a string in a multiple-selection list box.

To send this message, call the SendMessage function with the following parameters.

SendMessage(
  (HWND) hWnd,         // handle to destination window
  LB_SETSEL,           // message to send
  (WPARAM) wParam,     // selection option
  (LPARAM) lParam      // item index
);
Parameters
wParam
Specifies how to set the selection. If this parameter is TRUE, the string is selected and highlighted; if it is FALSE, the highlight is removed and the string is no longer selected.
lParam
Specifies the zero-based index of the string to set. If this parameter is –1, the selection is added to or removed from all strings, depending on the value of wParam.
Return Values
If an error occurs, the return value is LB_ERR.

Remarks
Use this message only with multiple-selection list boxes.

0
 
LVL 1

Accepted Solution

by:
jploeg earned 125 total points
ID: 9781699
Maybe you could replace the listbox with a list ctrl (in report view), and set the "show selection always" property.
0
 

Author Comment

by:MCofer
ID: 9782024
Ok I'm new to this using   SendMessage( hDlg,LB_SETSEL,TRUE,0);
I get:
error C2660: 'SendMessageA' : function does not take 4 parameters  ??

I also tried this. It compiles but does not work;
m_List is the ListBox Control
void MyDlg::OnRadioBtn1()
{
m_List.SendMessage( LB_SETSEL,TRUE,0);
}
0
 

Author Comment

by:MCofer
ID: 9782096
I just found my mistake
I am using a ListControl not a listBox.
If this takes more effort I can add some more points
Thanks
0
 

Author Comment

by:MCofer
ID: 9782289
Ok I found the answer The Items were still actually selected
so all I needed to to was  SetFocus() to rehighlight
Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question