Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CListCtrl

Status
Not open for further replies.

bubu123

Programmer
Sep 11, 2002
4
0
0
RO
Hello
I want to change the color which appears when i select an item from a CListCtrl control .Does anyone know give a link or a sample with something like this?
Thanks
 
All you have to do is to modify member function Create:
BOOL CListCtrl.Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );

dwStyle :
LVS_SHOWSELALWAYS - Always show the selection, if any, even if the control does not have the focus

and

LVS_SINGLESEL - Allows only one item at a time to be selected. By default, multiple items can be selected

For Doc/View You can try:

BOOL CAplView::preCreateWindow(CREATESTRUCT& cs)
{
// default processing
BOOL bReturn = CListView::preCreateWindow(cs);
// the list is in report mode by default
cs.style |= LVS_REPORT;
// the list is single selection only
cs.style |= LVS_SINGLESEL;
// the selected item stays in the selected color even
// if the list view loses focus
cs.style |= LVS_SHOWSELALWAYS;
return bReturn;
}


If you want more help please read MSDN Lib on your install CD.
 
ok, but how can i change the color?The default is blue, and i want change this color.
Thanks
 
I think that you can't do what you want, but there is a way
just make your view class derivate from CView and create all functions you need. Sorry i can't halp you with enything more.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top