Click here to Skip to main content
15,888,521 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Subitem hiliting in CListCtrl Pin
led mike30-Sep-08 4:25
led mike30-Sep-08 4:25 
GeneralRe: Subitem hiliting in CListCtrl Pin
josip cagalj30-Sep-08 20:59
josip cagalj30-Sep-08 20:59 
AnswerRe: Subitem hiliting in CListCtrl [modified] Pin
Naveen30-Sep-08 20:27
Naveen30-Sep-08 20:27 
GeneralRe: Subitem hiliting in CListCtrl Pin
josip cagalj30-Sep-08 21:43
josip cagalj30-Sep-08 21:43 
GeneralRe: Subitem hiliting in CListCtrl Pin
Naveen30-Sep-08 21:55
Naveen30-Sep-08 21:55 
GeneralRe: Subitem hiliting in CListCtrl [modified] Pin
josip cagalj30-Sep-08 22:12
josip cagalj30-Sep-08 22:12 
GeneralRe: Subitem hiliting in CListCtrl Pin
Naveen30-Sep-08 22:29
Naveen30-Sep-08 22:29 
GeneralRe: Subitem hiliting in CListCtrl Pin
josip cagalj1-Oct-08 3:07
josip cagalj1-Oct-08 3:07 
I've found some code and applied it:
onClick:
void CIMAPIListCtrl::OnClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NMLISTVIEW * pLV = reinterpret_cast<nmlistview>(pNMHDR);
	LVHITTESTINFO stInfo = {0};
    stInfo.pt = pLV->ptAction;
    SubItemHitTest( &stInfo );
	int nRow = stInfo.iItem;
	int nClmn = stInfo.iSubItem;
	if (nRow != -1)
	{
		if (m_nSubItemSelect != nClmn)
		{
		  m_nSubItemSelect = nClmn;
		  m_nCurrentlySelectedItem = nRow;

		  CRect rcItem;
		  GetItemRect(nRow, rcItem, LVIR_BOUNDS);
		  InvalidateRect(rcItem);
		}
	}
	*pResult = 0;
}</nmlistview>

onCustomDraw:
void CIMAPIListCtrl::OnCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<nmlvcustomdraw*>(pNMHDR);
	*pResult = 0;

	if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
	{
		*pResult = CDRF_NOTIFYSUBITEMDRAW;
	}
	else if (pLVCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM))
	{
		CDC*     pDC   = CDC::FromHandle ( pLVCD->nmcd.hdc );
		CRect rct;
		GetSubItemRect(m_nCurrentlySelectedItem,m_nSubItemSelect,LVIR_BOUNDS,rct);

		if ((m_nSubItemSelect == pLVCD->iSubItem) &&
			(GetItemState(pLVCD->nmcd.dwItemSpec, LVIS_SELECTED) == LVIS_SELECTED) &&
			 m_nCurrentlySelectedItem == pLVCD->nmcd.dwItemSpec )
		{
			//hilite
			pDC->FillSolidRect ( rct, RGB(0,0,255) );
			pDC->SetTextColor(RGB(255,255,255));
		}
		else
		{
			pDC->FillSolidRect ( rct, RGB(255,255,255) );
			pDC->SetTextColor(RGB(0,0,0));
		}
	}
}

My code never reaches inside else if (pLVCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM)) this is because I'm setting vrong value with *pResult = CDRF_NOTIFYSUBITEMDRAW;??
GeneralRe: Subitem hiliting in CListCtrl Pin
Naveen1-Oct-08 14:18
Naveen1-Oct-08 14:18 
GeneralRe: Subitem hiliting in CListCtrl Pin
josip cagalj1-Oct-08 22:42
josip cagalj1-Oct-08 22:42 
GeneralRe: Subitem hiliting in CListCtrl Pin
Naveen1-Oct-08 22:54
Naveen1-Oct-08 22:54 
GeneralRe: Subitem hiliting in CListCtrl [modified] Pin
josip cagalj1-Oct-08 23:14
josip cagalj1-Oct-08 23:14 
GeneralRe: Subitem hiliting in CListCtrl Pin
josip cagalj2-Oct-08 0:59
josip cagalj2-Oct-08 0:59 
AnswerRe: Subitem hiliting in CListCtrl Pin
josip cagalj30-Sep-08 21:49
josip cagalj30-Sep-08 21:49 
AnswerRe: Subitem hiliting in CListCtrl Pin
josip cagalj30-Sep-08 21:50
josip cagalj30-Sep-08 21:50 
QuestionProblem with VScroll Bar. [modified] Pin
Le@rner30-Sep-08 2:28
Le@rner30-Sep-08 2:28 
AnswerRe: Problem with VScroll Bar. Pin
Sarath C30-Sep-08 3:25
Sarath C30-Sep-08 3:25 
GeneralRe: Problem with VScroll Bar. Pin
Le@rner3-Oct-08 19:46
Le@rner3-Oct-08 19:46 
GeneralRe: Problem with VScroll Bar. Pin
Sarath C3-Oct-08 23:28
Sarath C3-Oct-08 23:28 
QuestionTraverse System Volume Information Folder Pin
john563230-Sep-08 2:02
john563230-Sep-08 2:02 
AnswerRe: Traverse System Volume Information Folder [modified] Pin
Michael Schubert30-Sep-08 2:30
Michael Schubert30-Sep-08 2:30 
QuestionRe: Traverse System Volume Information Folder Pin
john563230-Sep-08 20:09
john563230-Sep-08 20:09 
AnswerRe: Traverse System Volume Information Folder Pin
Michael Schubert30-Sep-08 20:20
Michael Schubert30-Sep-08 20:20 
QuestionMFC dll creation Pin
AnithaSubramani30-Sep-08 1:58
AnithaSubramani30-Sep-08 1:58 
AnswerRe: MFC dll creation Pin
_AnsHUMAN_ 30-Sep-08 2:25
_AnsHUMAN_ 30-Sep-08 2:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.