Click here to Skip to main content
15,883,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
void CMyTrre::OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTVCUSTOMDRAW pCustomDraw = reinterpret_cast<LPNMTVCUSTOMDRAW>(pNMHDR);
	*pResult = 0;


	NMTVCUSTOMDRAW *pcd = (NMTVCUSTOMDRAW   *)pNMHDR;
	switch (pcd->nmcd.dwDrawStage)
	{
	case CDDS_PREPAINT:
		*pResult = CDRF_NOTIFYITEMDRAW;
		break;

	case CDDS_ITEMPOSTPAINT:
	{	
		HTREEITEM   hItem = (HTREEITEM)pcd->nmcd.dwItemSpec;
		
		CString giorno;
		giorno = GetItemText(hItem);//ottengo il mese o giorno
		int n_pos;
		n_pos = giorno.Find(_T("a"));
		if (n_pos >= 0)
		{
			//Rectangle(pcd->nmcd.hdc, pcd->nmcd.rc.left, pcd->nmcd.rc.top, pcd->nmcd.rc.right, pcd->nmcd.rc.bottom);
			pcd->nmcd.rc.right = pcd->nmcd.rc.right + 30;
		//	pcd->nmcd.rc.bottom = pcd->nmcd.rc.bottom + 20;
			pcd->nmcd.rc.top = pcd->nmcd.rc.top + 23;
			DrawText(pcd->nmcd.hdc, _T("10:31pm"), 7, &pcd->nmcd.rc, DT_CENTER);
		}
	
		*pResult = CDRF_DODEFAULT;// do not set *pResult = CDRF_SKIPDEFAULT
		break;
	  }
	}
}
ITEMPOSTPAINT in debug isn't called, what's the problem

What I have tried:

whit ITEMPREPAINT I haven't problem
Posted
Updated 24-Feb-22 5:21am
v3

1 solution

Normally custom drawing is done a bit different. Read Microsoft documentation with its sample code.

Take also a look at this well written legandary article and its code.
 
Share this answer
 
Comments
Member 14594285 24-Feb-22 11:33am    
I tried but in this way treeView isn't drawn, I have the problem that I must write on treView and I want item rectangle transparent

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900