void COutlook2Ctrl::DrawSubItems(CDC * pDC, COL2Folder * oFolder, COL2Item * iItem, CRect & rect)
{
	if (rect.bottom - m_iSubItemHeight < rect.top) return;

	CPoint pt;
	GetCursorPos(&pt);
	ScreenToClient(&pt);
	
	for (int t1 = 0; t1 < iItem->m_SubItems.GetSize(); t1++)
	{
		COL2SubItem * p = (COL2SubItem *) iItem->m_SubItems.GetAt(t1);
		if (p->hHostedWnd)
		{
			int dy;
			if (p->lParam == 0xFFFFFFFF) dy = rect.Height(); else dy = (int) p->lParam;

			p->rcItem.SetRect(rect.left+1,rect.top,rect.right-1,rect.top+dy);

			::SetWindowPos(p->hHostedWnd, NULL,p->rcItem.left, p->rcItem.top, p->rcItem.Width(), p->rcItem.Height(), SWP_NOZORDER);
			if (!::IsWindowVisible(p->hHostedWnd)) ::ShowWindow(p->hHostedWnd, SW_SHOW);
			rect.top += dy;
		}
		else
		{
			p->rcItem.SetRect(rect.left+1,rect.top,rect.right-1,rect.top+m_iSubItemHeight);
			DrawSubItem(pDC, oFolder, iItem, p, p->rcItem.PtInRect(pt) ? true : false);
			rect.top += m_iSubItemHeight;
		}
		
		if (rect.top >= rect.bottom - m_iSubItemHeight) break;
	}
}
示例#2
0
void CRichListCtrl::DrawItem(CDC* pDC, int nItem, CRect &rcItem)  
{  
	if (nItem < 0 || nItem >= (int)m_vctItem.size())
	{
		return;
	}

	bool bSelected = false;  
	if (GetItemState(nItem, LVIS_SELECTED))  
	{  
		bSelected = true;  
	}  

	bool bFocus = false;  
	CWnd *pWndFocus = GetFocus();  
	if (IsChild(pWndFocus) || pWndFocus == this)  
	{  
		bFocus = true;  
	}  

	int pos = GetScrollPos(SB_HORZ);  
	int nColumnCount = GetHeaderCtrl()->GetItemCount();  
	CRect  rcSubItem;  
	for (int j = 0; j < nColumnCount; ++j)  
	{  
		GetHeaderCtrl()->GetItemRect(j, &rcSubItem);  
		rcSubItem.top = rcItem.top;  
		rcSubItem.bottom = rcItem.bottom;  
		rcSubItem.OffsetRect(-pos, 0);  
		if(rcSubItem.right < rcItem.left || rcSubItem.left > rcItem.right)  
		{
			continue;  
		}

		map<int, ListSubItem*>::iterator it = m_vctItem[nItem].find(j);
		if (it == m_vctItem[nItem].end() || it->second->itemType == CTRL_STATIC)
		{
			DrawSubItem(pDC, nItem, j, rcSubItem, bSelected, bFocus);
		}
		else if (it->second->itemType == CTRL_BUTTON)
		{
			CButton *pButton = (CButton*)(it->second->pItem);
			if (pButton != NULL)
			{		
				pButton->ShowWindow(SW_SHOW);
				pButton->MoveWindow(rcSubItem);
			}
		}
	}   
}  
示例#3
0
//自绘函数
void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CPoint Point;
	CRect Rect = lpDrawItemStruct->rcItem;
	CRect ClientRect;
	GetItemRect(0,ClientRect,LVIR_BOUNDS);
	
	int RowIndex=0;
	if(Rect.top != ClientRect.top )
	{
		RowIndex=(Rect.top-ClientRect.top)/m_RowHeight; 
		if((Rect.top-ClientRect.top)%m_RowHeight)
			RowIndex+=1;
	}
	CDC dc;
	dc.Attach(lpDrawItemStruct->hDC);
	//CRect fillRect = Rect;
	//fillRect.InflateRect(1,1,1,1);
	//dc.FillSolidRect(Rect, (COLORREF)RGB(0xff, 0xff, 0xff));
	
	
	int Offset=0;
	for(int ColumnIndex = 0; ColumnIndex <= m_ColumnCount; ColumnIndex++)
	{
		CRect TempRect=Rect;
		int Width =GetColumnWidth(ColumnIndex);
		TempRect.left= Offset;
		TempRect.right = Offset + Width;
		Offset+=Width;
		//Rect = TempRect;
		//Rect.InflateRect(1,1,2,2);
		dc.FillSolidRect(TempRect, (COLORREF)RGB(0xff, 0xff, 0xff));
		if(lpDrawItemStruct->itemID%2 && m_ShowOther)
		{
			dc.FillSolidRect(TempRect, (COLORREF)RGB(0xe8, 0xe8, 0xe8));
		}
		DrawSubItem(&dc,RowIndex,ColumnIndex,TempRect);	
	}
	CRect tRect = Rect;
	tRect.top = tRect.bottom - 1;
	tRect.bottom += 1;
	dc.FillSolidRect(tRect, (COLORREF)RGB(0xff, 0xff, 0xff));
	tRect = Rect;
	tRect.left = Rect.right - 1;
	tRect.right += 1;
	dc.FillSolidRect(tRect, (COLORREF)RGB(0xff, 0xff, 0xff));
	if(lpDrawItemStruct->itemID%2 && m_ShowOther)
	{
		tRect = Rect;
		tRect.top = tRect.bottom - 1;
		tRect.bottom += 1;
		dc.FillSolidRect(tRect, (COLORREF)RGB(0xe8, 0xe8, 0xe8));
		tRect = Rect;
		tRect.left = Rect.right - 1;
		tRect.right += 1;
		dc.FillSolidRect(tRect, (COLORREF)RGB(0xe8, 0xe8, 0xe8));
		
	}
	//while(Rect.bottom + m_RowHeight < ClientRect.bottom)
	//{
	//	dc.MoveTo(Rect.left,Rect.bottom);
	//	dc.LineTo(Rect.right,Rect.bottom);
	//	Rect.bottom+=m_RowHeight;
	//}
	dc.Detach();
}
void COutlook2Ctrl::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_iDragging == 1)
	{
		CRect rc1(m_dragRect);
		m_dragRect.SetRect(point.x-5 + m_iDragoffset, rc1.top, point.x + m_iDragoffset, rc1.bottom);
		if (rc1 != m_dragRect)
		{
			OnInvertTracker(rc1);
			OnInvertTracker(m_dragRect);
		}
	}
	else
	{
		int f,i,s;
		int r = HitTest(f,i,s,point);
		if (r == 1)
		{
			CClientDC dc(this); 
			if (iHiFolder >= 0 && iHiFolder != f)
			{
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false);
			}
			if (iHiFolder != f)
			{
				iHiFolder = f;
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, true);
			}
		}
		if (r == 4)
		{
			COL2SubItem	* ps = GetSubItem(f,i,s);
			CClientDC dc(this); 
			if (pLastHilink && pLastHilink != ps)
			{
				DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false);
			}
			if (pLastHilink != ps)
			{
				pLastHilink = ps;
				DrawSubItem(&dc, GetFolder(f), GetItem(f,i), ps, true);
				iHilinkFolder = f;
				iHilinkItem = i;
			}
		}

		if (r == 0)
		{
			if (iHiFolder >= 0)
			{
				CClientDC dc(this); 
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false);
				iHiFolder = -1;
			}
			if (pLastHilink != NULL)
			{
				CClientDC dc(this); 
				DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false);
				pLastHilink = NULL;
			}
		}
	}

	OLCTRL2_BASE_CLASS::OnMouseMove(nFlags, point);
}