Click here to Skip to main content
15,901,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Generated message map functions //{{AFX_MSG limits?? Pin
ShilpiP5-Oct-06 1:53
ShilpiP5-Oct-06 1:53 
GeneralRe: MFC Generated message map functions //{{AFX_MSG limits?? Pin
Rajesh R Subramanian5-Oct-06 2:17
professionalRajesh R Subramanian5-Oct-06 2:17 
AnswerRe: MFC Generated message map functions //{{AFX_MSG limits?? Pin
krmed5-Oct-06 1:59
krmed5-Oct-06 1:59 
GeneralRe: MFC Generated message map functions //{{AFX_MSG limits?? Pin
Vaclav_5-Oct-06 6:29
Vaclav_5-Oct-06 6:29 
QuestionCListView problem with editing items Pin
Mohammad A Gdeisat4-Oct-06 17:35
Mohammad A Gdeisat4-Oct-06 17:35 
AnswerRe: CListView problem with editing items Pin
Mark Salsbery4-Oct-06 18:12
Mark Salsbery4-Oct-06 18:12 
GeneralRe: CListView problem with editing items Pin
Mohammad A Gdeisat4-Oct-06 23:46
Mohammad A Gdeisat4-Oct-06 23:46 
GeneralRe: CListView problem with editing items Pin
Mark Salsbery5-Oct-06 7:05
Mark Salsbery5-Oct-06 7:05 
>>but how does this affect editing labels?

It effects almost everything. When you use LVS_OWNERDATA the control only maintains information
about what item is selected and the control's focus. It's up to you to provide the rest.
When it needs text you provide the text. When it needs the image (icon) you provide it, etc.

LVN_GETDISPINFO is sent to the parent of the control.

In the parent window class, add a OnNotify() function (handler for WM_NOTIFY).
In this example I've used the item's lParam to store an index into some array of structures
which hold the info for each item in the list. I've shown a way to handle LVN_GETDISPINFO for
LVIF_TEXT and LVIF_IMAGE. This would be the bare minimum you'd need to provide to the control.
(Actually I don't think items HAVE to have an image Smile | :) )
All the other notifications are dispatched to functions I've added to my CMyCWndDerivedClass
class...

BOOL CMyCWndDerivedClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
	NMHDR *pHdr = (NMHDR *)lParam; 

	if (wParam == IDC_MYLISTVIEWCTRL)
	{
		if (pHdr->code == LVN_GETDISPINFO)
		{
			NMLVDISPINFO *pLVDispInfo = (NMLVDISPINFO *)pHdr;

			if (pLVDispInfo->item.mask | LVIF_TEXT)
			{
				LVITEM LVItem;
				LVItem.mask = LVIF_PARAM; 
				LVItem.iItem = pLVDispInfo->item.iItem; 
				LVItem.iSubItem = 0; 
				pListCtrl->GetItem(&LVItem); 
				int nItemIndex = (int)LVItem.lParam;

				if (nItemIndex >= 0)
				{
					pLVDispInfo->item.pszText = <--(point this to the row's text)
				}
				else
				{
					pLVDispInfo->item.pszText = _T("ERROR");
				}
			}
			if (pLVDispInfo->item.mask | LVIF_IMAGE)
			{
				LVITEM LVItem;
				LVItem.mask = LVIF_PARAM; 
				LVItem.iItem = pLVDispInfo->item.iItem; 
				LVItem.iSubItem = 0; 
				pListCtrl->GetItem(&LVItem); 
				int nItemIndex = (int)LVItem.lParam;
				pLVDispInfo->item.iImage = <--(provide index into image list here)
			}  
			return TRUE;
		}
		else if (pHdr->code == LVN_BEGINDRAG)
		{
			LvnBeginDrag((NMLISTVIEW *)lParam);
			return TRUE;
		}
		else if (pHdr->code == LVN_ITEMCHANGED)
		{
			LvnItemChanged((NMLISTVIEW *)¬ifyInfo);
			return TRUE;
		}
		else if (pHdr->code == LVN_ITEMACTIVATE)
		{
			LvnItemActivate((NMITEMACTIVATE *)¬ifyInfo);
			return TRUE;
		}
		else if (pHdr->code == NM_RCLICK)
		{
			ListRClick((NMLISTVIEW *)lParam);
			return TRUE;
		}
		else if (pHdr->code == NM_DBLCLK)
		{
			ListDblClick((NMLISTVIEW *)lParam);
			return TRUE;
		}
		else if (pHdr->code == LVN_BEGINLABELEDIT)
		{
			return LvnBeginLabelEdit((NMLVDISPINFO *)lParam);
		}
		else if (pHdr->code == LVN_ENDLABELEDIT)
		{
			return LvnEndLabelEdit((NMLVDISPINFO *)lParam);
		}
		else if (pHdr->code == LVN_COLUMNCLICK)
		{
			LvnColumnClick((NMLISTVIEW *)lParam);
			return TRUE;
		}

	}  //if (wParam == IDC_MYLISTVIEWCTRL)

	return CWnd::OnNotify(wParam, lParam, pResult);
}

GeneralRe: CListView problem with editing items Pin
Mark Salsbery5-Oct-06 7:10
Mark Salsbery5-Oct-06 7:10 
QuestionBorland C++ Pin
seec00024-Oct-06 17:27
seec00024-Oct-06 17:27 
AnswerRe: Borland C++ Pin
Christian Graus4-Oct-06 18:56
protectorChristian Graus4-Oct-06 18:56 
GeneralRe: Borland C++ Pin
seec00024-Oct-06 19:17
seec00024-Oct-06 19:17 
AnswerRe: Borland C++ Pin
Monty24-Oct-06 20:44
Monty24-Oct-06 20:44 
QuestionOperator overloading Pin
Waldermort4-Oct-06 16:00
Waldermort4-Oct-06 16:00 
AnswerRe: Operator overloading Pin
Stephen Hewitt4-Oct-06 16:21
Stephen Hewitt4-Oct-06 16:21 
AnswerRe: Operator overloading Pin
Mark Salsbery4-Oct-06 16:29
Mark Salsbery4-Oct-06 16:29 
GeneralRe: Operator overloading Pin
Waldermort4-Oct-06 16:55
Waldermort4-Oct-06 16:55 
GeneralRe: Operator overloading Pin
Mark Salsbery4-Oct-06 17:04
Mark Salsbery4-Oct-06 17:04 
AnswerRe: Operator overloading Pin
Nibu babu thomas4-Oct-06 17:34
Nibu babu thomas4-Oct-06 17:34 
GeneralRe: Operator overloading Pin
Waldermort4-Oct-06 18:17
Waldermort4-Oct-06 18:17 
GeneralRe: Operator overloading Pin
Nibu babu thomas4-Oct-06 18:19
Nibu babu thomas4-Oct-06 18:19 
AnswerRe: Operator overloading Pin
Waldermort4-Oct-06 18:48
Waldermort4-Oct-06 18:48 
GeneralRe: Operator overloading Pin
Waldermort4-Oct-06 19:10
Waldermort4-Oct-06 19:10 
GeneralRe: Operator overloading Pin
Niklas L5-Oct-06 3:12
Niklas L5-Oct-06 3:12 
AnswerRe: Operator overloading Pin
David Crow5-Oct-06 3:17
David Crow5-Oct-06 3:17 

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.