15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Keeping CListCtrl selection

George Grant -- ggrant@ns.net
Friday, May 10, 1996

Environment: VC++ 4.0 Win95

Is there any way to have a CListCtrl keep its current selection =
hilighted when the control loses the focus? I've tried using the =
control's KillFocus handler to set the selected flag in the "selected" =
item's state flags, but that didn't seem to work. Am I going to have to =
write a whole custom drawing proc just to handle this one thing? That =
would be a serious bummer...

-George Grant
Air Toxics Ltd.




Glenn T. Jayaputera -- gtj@nunkeen.apana.org.au
Monday, May 13, 1996

[Mini-digest: 7 responses]

Yep,
in your control property turn on "show  selection always"

glenn tesla

-----From: Ray Kaminski 

For some reason the LVS_SHOWSELALWAYS does not seem to be an option from 
within the resource editor in MSDEV.  I do not know if this was an 
oversight or what.  You can change the RC file directly or call ModifyStyle 
in OnInitDialog and change the style.  It appears to work fine as I have 
now used it on several occasions.

-----From: "Frederic Steppe" 

Add the LVS_SHOWSELALWAYS style to you control.

Frederic Steppe(frederics@msn.com)
-----From: "Andrew Solberg" 

Try this in InitDialog or whatever, where m_CodeList is my CListCtrl.

// set style so that list view will show its selections even when the
// control loses focus
LONG styleResList = ::GetWindowLong(m_CodeList.m_hWnd, GWL_STYLE);
::SetWindowLong(m_CodeList.m_hWnd, GWL_STYLE, styleResList |
LVS_SHOWSELALWAYS);

-----From: Mario Contestabile 

Try using LVS_SHOWSELALWAYS.
mcontest@universal.com
-----From: "Mike Ward" 

Try the LVS_SHOWSELALWAYS style.  Don't feel bad, I had to ask the
same question on compuserve about 3 months ago.  I don't know about
the rest of you folks, but I find the real battle of programming
these days is not getting things to work but finding the information
on how things work. 

-----From: Nancy Enright 

Use LVS_SHOWSELALWAYS.

 I call CDisplayPg::SetListCtrlSyle() at the end of OnInitDialog.  It sets 
LVS_SHOWSELALWAYS so that the CListCtrl selection shows even if the control 
does not have the focus. 

void CDisplayPg::SetListCtrlSyle()
{
    LONG lStyle;
// set the LVS_SHOWSELALWAYS so that the selection shows even if the
// control does not have the focus.

 // color
    lStyle = GetWindowLong (m_pListColorMono->m_hWnd, GWL_STYLE);
    lStyle |= LVS_SHOWSELALWAYS;
    SetWindowLong (m_pListColorMono->m_hWnd, GWL_STYLE, lStyle);
}

- Nancy Enright
nenright@idea.com




| Вернуться в корень Архива |