Solved

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

Posted on 2003-11-19
5
348 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the real difference between C++ and Visual C++.NET? 7 131
convert char array to number in c 5 89
c++, dynamic object by json 1 59
Finding Divisors 5 35
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

680 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