Solved

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

Posted on 2003-11-19
5
312 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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…
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now