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

C / C++ / MFC

 
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 
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 
Nave, thank you very much for helping me!
My code now looks like this:
void CIMAPIListCtrl::OnClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NMLISTVIEW * pLV = reinterpret_cast<nmlistview>(pNMHDR);
	LVHITTESTINFO stInfo = {0};
	if(m_nSubItemSelect != -1 && m_nCurrentlySelectedItem != -1)
	{
		//remove old selection JOSIP
		CRect rcItem;
		GetItemRect(m_nCurrentlySelectedItem, rcItem, LVIR_BOUNDS);
		InvalidateRect(rcItem);
	}
    stInfo.pt = pLV->ptAction;
    SubItemHitTest( &stInfo );
	int nRow = stInfo.iItem;
	int nClmn = stInfo.iSubItem;
	if(GetItemText(nRow,nClmn)=="") return;
	if (nRow != -1)
	{
		if (m_nSubItemSelect != nClmn)
		{
		  m_nSubItemSelect = nClmn;
		  m_nCurrentlySelectedItem = nRow;

		  CRect rcItem;
		  GetItemRect(nRow, rcItem, LVIR_BOUNDS);
		  InvalidateRect(rcItem);
		}
	}
	*pResult = 0;
	
}

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

	if ( pLVCD->nmcd.dwDrawStage == CDDS_PREPAINT )
	{
		*pResult = CDRF_NOTIFYITEMDRAW;
	}
	else if (pLVCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
	{
		*pResult = CDRF_NOTIFYSUBITEMDRAW;
	}
	else if (pLVCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM))
	{
		if((m_nSubItemSelect == pLVCD->iSubItem) && 
			(pLVCD->nmcd.uItemState & CDIS_SELECTED)==CDIS_SELECTED && 
			m_nCurrentlySelectedItem == pLVCD->nmcd.dwItemSpec)
		{
			pLVCD->clrTextBk = RGB(0,0,255);
			pLVCD->clrText = RGB(255,255,255);
		}
		else
		{
			pLVCD->clrTextBk = RGB(255,255,255);
			pLVCD->clrText = RGB(0,0,0);
			pLVCD->nmcd.uItemState = pLVCD->nmcd.uItemState& ~CDIS_SELECTED;
		}
	}
}
</nmlistview>

The problem is that for hiliting subitem I need first to click on column 0 and then subitem column to work. Exception is when clicking on first row after listctrl is populated!
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 
AnswerRe: MFC dll creation Pin
SandipG 30-Sep-08 3:03
SandipG 30-Sep-08 3:03 
QuestionIcons Pin
Sarriss30-Sep-08 1:56
Sarriss30-Sep-08 1:56 

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.