Click here to Skip to main content
15,890,825 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ISAPI FILTER ON ISA SERVER Pin
SuzannaS20-May-04 21:38
SuzannaS20-May-04 21:38 
Questionhow to set multi color subitem in CListCtrl grid? Pin
george ivanov18-May-04 3:55
george ivanov18-May-04 3:55 
AnswerRe: how to set multi color subitem in CListCtrl grid? Pin
RChin18-May-04 4:13
RChin18-May-04 4:13 
GeneralRe: how to set multi color subitem in CListCtrl grid? Pin
Roger Allen18-May-04 4:34
Roger Allen18-May-04 4:34 
GeneralRe: how to set multi color subitem in CListCtrl grid? Pin
alex.barylski18-May-04 4:37
alex.barylski18-May-04 4:37 
GeneralRe: how to set multi color subitem in CListCtrl grid? Pin
RChin18-May-04 5:25
RChin18-May-04 5:25 
GeneralRe: how to set multi color subitem in CListCtrl grid? Pin
george ivanov18-May-04 8:38
george ivanov18-May-04 8:38 
AnswerRe: how to set multi color subitem in CListCtrl grid? Pin
chris10918-May-04 5:11
chris10918-May-04 5:11 
I suppose your control already has the LVS_REPORT style.
In the window or dialog containing the CListCtrl, add a NM_CUSTOMDRAW notification. Then just code the different colors you wish in the added notification method, like in the following example (for more information, see:
Customizing a Control's Appearance Using Custom Draw, in MSDN
Owner-draw CListCtrl MFC app at http://www.simtel.net/pub/pd/15298.shtml)

void CTestListCtrlDlg::OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult)<br />
{<br />
	LPNMLVCUSTOMDRAW pNMCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);<br />
<br />
	*pResult = 0;	<br />
<br />
	// If this is the beginning of the control's paint cycle, request<br />
    // notifications for each item.<br />
	switch(pNMCD->nmcd.dwDrawStage)<br />
	{<br />
	case CDDS_PREPAINT:<br />
		*pResult = CDRF_NOTIFYITEMDRAW;<br />
		break;<br />
<br />
	case CDDS_ITEMPREPAINT:<br />
		// This is the prepaint stage for an item<br />
<br />
		// Tell Windows to notify sub-items painting<br />
		*pResult = CDRF_NOTIFYSUBITEMDRAW;<br />
		break;<br />
<br />
	case CDDS_SUBITEM | CDDS_ITEMPREPAINT:<br />
		// This is the prepaint stage for a sub-item<br />
		switch(pNMCD->iSubItem) {<br />
		case 0:<br />
			// Item<br />
			switch(pNMCD->nmcd.dwItemSpec) {<br />
			case 0:<br />
				// First item: black text, blue background<br />
				pNMCD->clrText = RGB(0,0,0);<br />
				pNMCD->clrTextBk = RGB(0,255,255);<br />
				break;<br />
			default:<br />
				// Next items: black text, white background<br />
				pNMCD->clrText = RGB(0,0,0);<br />
				pNMCD->clrTextBk = RGB(255,255,255);<br />
				break;<br />
			}<br />
			break;<br />
		case 1:<br />
			// First sub-item: red text, yellow background<br />
			pNMCD->clrText = RGB(255,0,0);<br />
			pNMCD->clrTextBk = RGB(255,255,0);<br />
			break;<br />
		default:<br />
			// Next sub-items: black text, white background<br />
			pNMCD->clrText = RGB(0,0,0);<br />
			pNMCD->clrTextBk = RGB(255,255,255);<br />
			break;<br />
		}<br />
		// Tell Windows to paint the control itself.<br />
		*pResult = CDRF_DODEFAULT;<br />
		break;<br />
<br />
	default:<br />
		// Tell Windows to paint the control itself.<br />
		*pResult = CDRF_DODEFAULT;<br />
		break;<br />
	}<br />
}


Friendly yours, Chris
GeneralRe: how to set multi color subitem in CListCtrl grid? Pin
george ivanov18-May-04 22:44
george ivanov18-May-04 22:44 
AnswerIf you want an EZ-Pass... Pin
Abin18-May-04 7:18
Abin18-May-04 7:18 
QuestionHow to read byte array sent by api from managed c++ Pin
hasansheik18-May-04 3:47
hasansheik18-May-04 3:47 
GeneralFile's length over HTTP Pin
Hans Ruck18-May-04 3:37
Hans Ruck18-May-04 3:37 
GeneralRe: File's length over HTTP Pin
Michael Dunn18-May-04 4:55
sitebuilderMichael Dunn18-May-04 4:55 
GeneralRe: File's length over HTTP Pin
Hans Ruck18-May-04 5:00
Hans Ruck18-May-04 5:00 
QuestionHow to use mutex in a dll Pin
yingkou18-May-04 2:49
yingkou18-May-04 2:49 
AnswerRe: How to use mutex in a dll Pin
Diddy18-May-04 4:46
Diddy18-May-04 4:46 
GeneralRe: How to use mutex in a dll Pin
yingkou18-May-04 14:08
yingkou18-May-04 14:08 
GeneralRe: How to use mutex in a dll Pin
Diddy18-May-04 23:40
Diddy18-May-04 23:40 
GeneralRe: How to use mutex in a dll Pin
yingkou19-May-04 2:26
yingkou19-May-04 2:26 
GeneralRe: How to use mutex in a dll Pin
Diddy19-May-04 2:45
Diddy19-May-04 2:45 
GeneralRe: How to use mutex in a dll Pin
yingkou19-May-04 3:55
yingkou19-May-04 3:55 
GeneralRe: How to use mutex in a dll Pin
Diddy19-May-04 10:08
Diddy19-May-04 10:08 
GeneralUnreferenced memory Pin
krugger18-May-04 2:28
krugger18-May-04 2:28 
GeneralRe: Unreferenced memory Pin
Cedric Moonen18-May-04 2:37
Cedric Moonen18-May-04 2:37 
GeneralRe: Unreferenced memory Pin
David Crow18-May-04 3:14
David Crow18-May-04 3:14 

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.