Click here to Skip to main content
14,301,895 members
Rate this:
Please Sign up or sign in to vote.
See more:
Here is the code I have used but i am not getting the proper message

//creating the list view
hListView=CreateWindowEx(0,L"SysListView32",NULL,
				WS_CHILD|WS_VISIBLE|LVS_REPORT|WS_BORDER|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP|WS_GROUP|LVS_AUTOARRANGE|LVS_ALIGNLEFT,10,50,rc.right-10,rc.bottom-50,hWnd,(HMENU)DISP_LISTVIEW,(HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),NULL);
 
//for extended style
int estyle=LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES| LVS_EX_HEADERDRAGDROP;
ListView_SetExtendedListViewStyle(hListView,estyle);
 
//in the WndProc function

case WM_NOTIFY:
	NMHDR *nmhdr;
	nmhdr=(NMHDR*)lParam;
	switch(wParam)
	{
	case DISP_LISTVIEW:
	if(nmhdr->code==NM_CUSTOMDRAW)
	{
		LONG l=(LONG)TableDraw(lParam);
		SetWindowLong(hWnd, DWL_MSGRESULT, l);
                return TRUE;
	}
	else
        ...
     	...
 
//function to color row. copied from code project
LRESULT TableDraw (LPARAM lParam)
{
	int iRow;
	LPNMLVCUSTOMDRAW pListDraw = (LPNMLVCUSTOMDRAW)lParam;
	switch(pListDraw->nmcd.dwDrawStage)
	{
	case CDDS_ITEMPREPAINT:
//it never reach here
		iRow = (int)pListDraw->nmcd.dwItemSpec;
		if(iRow%2 == 0)
		{
			pListDraw->clrTextBk = RGB(202, 221,250);
			return CDRF_NEWFONT;
		}
	case CDDS_PREPAINT:
		return (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW);
	default:
		break;
	}
	return CDRF_DODEFAULT;
}


The application is a Multi-document interface application. and the HWND passed to SetWindow long is a child window of application. The Error code I am getting from GetLastError Function is 1413

Would you please let me know what I can do? where I am doing wrong?
Posted
Updated 12-Jun-12 15:20pm
v5

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

You should be checking for NM_CUSTOMDRAW every time you receive a WM_NOTIFY message. What is the test for DISP_LISTVIEW used for?
   
Comments
Lal Miah 13-Jun-12 20:54pm
   
DISP_LISTVIEW is the Id of Listview, thats how I know the requested ListView control. And I am using the NM_CUSTOMDRAW but I am not getting the message. instead I am getting error 1413
Richard MacCutchan 14-Jun-12 4:20am
   
Where are you getting the 1413 error?
Richard MacCutchan 14-Jun-12 4:23am
   
Also, take a look at the comments here with reference to the contents of the wParam values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100