Solved

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

Posted on 2003-11-19
5
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

615 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