当前位置: 首页>>代码示例>>C++>>正文


C++ CImageList::Draw方法代码示例

本文整理汇总了C++中CImageList::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ CImageList::Draw方法的具体用法?C++ CImageList::Draw怎么用?C++ CImageList::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CImageList的用法示例。


在下文中一共展示了CImageList::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawListImage

VOID CEasySkinTreeCtrl::DrawListImage( CDC * pDC, CRect rcRect, HTREEITEM hTreeItem, bool bSelected )
{
	CMapItemInfo::iterator iter= m_MapItemInfo.find(hTreeItem);
	if( iter == m_MapItemInfo.end() )
	{
		CImageList *pImageList = GetImageList(TVSIL_NORMAL);
		if( pImageList == NULL ) return;

		//获取属性
		INT nImage,nSelectedImage;
		GetItemImage(hTreeItem,nImage,nSelectedImage);

		//获取信息
		IMAGEINFO ImageInfo;
		pImageList->GetImageInfo(bSelected?nSelectedImage:nImage,&ImageInfo);

		//绘画图标
		INT nImageWidth=ImageInfo.rcImage.right-ImageInfo.rcImage.left;
		INT nImageHeight=ImageInfo.rcImage.bottom-ImageInfo.rcImage.top;

		pImageList->Draw(pDC,bSelected?nSelectedImage:nImage,CPoint(rcRect.left-nImageWidth-3,rcRect.top+(rcRect.Height()-nImageHeight)/2+1),ILD_TRANSPARENT);
	}
	else
	{
		CImageEx *pImage = iter->second.pImage;
		pImage->DrawImage(pDC,rcRect.left-pImage->GetWidth()-3,rcRect.top+(rcRect.Height()-pImage->GetHeight())/2+1);
	}
}
开发者ID:alon-zhong,项目名称:EasyClient,代码行数:28,代码来源:EasySkinTreeCtrl.cpp

示例2: onDrawSubItem

      /// <summary>Custom draws a single sub-item</summary>
      /// <param name="dc">Device context</param>
      /// <param name="item">Item data.</param>
      void  ListViewCustomDraw::onDrawSubItem(CDC* dc, ItemData& item)
      {
         // Get item data
         LVItem data(item.Index, item.SubItem, 512, LVIF_IMAGE | LVIF_TEXT);
         ListView.GetItem(&data);

         // Draw Icon:
         CImageList* imgList = ListView.GetImageList(LVSIL_SMALL);
         if (item.SubItem == 0 && imgList)
         {
            CRect icon;

            // Get icon rectangle
            ListView.GetSubItemRect(item.Index, 0, LVIR_ICON, icon);
            
            // Draw transparent
            if (!imgList->Draw(dc, data.iImage, icon.TopLeft(), ILD_TRANSPARENT))
               throw Win32Exception(HERE, VString(L"Unable to draw icon for item %d", item.Index));

            // Create gap betwen icon/label
            item.Rect.left += 3;
         }

         // Draw Text:
         dc->DrawText(data.pszText, item.Rect, DT_VCENTER|DT_LEFT|DT_END_ELLIPSIS|DT_SINGLELINE);
      }
开发者ID:CyberSys,项目名称:X-Studio-2,代码行数:29,代码来源:ListViewCustomDraw.cpp

示例3: DrawItem

void CClosableTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect rect = lpDrawItemStruct->rcItem;
	int nTabIndex = lpDrawItemStruct->itemID;
	if (nTabIndex < 0)
		return;
	BOOL bSelected = (nTabIndex == GetCurSel());

	TCHAR szLabel[256];
	TC_ITEM tci;
	tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
	tci.pszText = szLabel;
	tci.cchTextMax = ARRSIZE(szLabel);
	tci.dwStateMask = TCIS_HIGHLIGHTED;
	if (!GetItem(nTabIndex, &tci))
		return;

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (!pDC)
		return;

	int iOldBkMode = pDC->SetBkMode(TRANSPARENT);

	// Draw image on left side
	CImageList* piml = GetImageList();
	if (tci.iImage >= 0 && piml && piml->m_hImageList)
	{
		IMAGEINFO ii;
		piml->GetImageInfo(0, &ii);
		rect.left += bSelected ? 8 : 4;
		piml->Draw(pDC, tci.iImage, CPoint(rect.left, rect.top + 2), ILD_TRANSPARENT);
		rect.left += (ii.rcImage.right - ii.rcImage.left);
		if (!bSelected)
			rect.left += 4;
	}

	bool bCloseable = m_bCloseable;
	if (bCloseable && GetParent()->SendMessage(UM_QUERYTAB, nTabIndex))
		bCloseable = false;

	// Draw 'Close button' at right side
	if (bCloseable && m_ImgLstCloseButton.m_hImageList)
	{
		CRect rcCloseButton;
		GetCloseButtonRect(rect, rcCloseButton);
		m_ImgLstCloseButton.Draw(pDC, 0, rcCloseButton.TopLeft(), ILD_TRANSPARENT);
		rect.right = rcCloseButton.left - 2;
	}

	COLORREF crOldColor = RGB(0, 0, 0);
	if (tci.dwState & TCIS_HIGHLIGHTED)
		crOldColor = pDC->SetTextColor(RGB(192, 0, 0));

	rect.top += 4;
	pDC->DrawText(szLabel, rect, DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOPREFIX);

	if (tci.dwState & TCIS_HIGHLIGHTED)
		pDC->SetTextColor(crOldColor);
	pDC->SetBkMode(iOldBkMode);
}
开发者ID:BackupTheBerlios,项目名称:resurrection,代码行数:60,代码来源:ClosableTabCtrl.cpp

示例4: DrawTabIcon

void CXTPSkinObjectTab::DrawTabIcon(CDC* pDC, CRect& rcItem, int iItem)
{
	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	TC_ITEM tci;
	tci.mask = TCIF_IMAGE;

	BOOL bResult = pTabCtrl->GetItem(iItem, &tci);

#ifdef _UNICODE
	if (!bResult)
	{
		TC_ITEMA tcia;
		::ZeroMemory(&tcia, sizeof(TC_ITEMA));

		tcia.mask = TCIF_IMAGE;

		bResult = (BOOL)::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia);
		tci.iImage = tcia.iImage;
	}
#endif
	if (!bResult)
		return;

	CImageList* pImageList = pTabCtrl->GetImageList();
	if (!pImageList || tci.iImage < 0)
		return;

	CPoint point = rcItem.TopLeft();

	DWORD dwStyle = GetStyle();

	if (IsHorz(dwStyle))
	{
		point.Offset(GetMetrics()->m_cxEdge * 2, IsTop(dwStyle) ? GetMetrics()->m_cyEdge : 1);
	}
	else
	{
		point.Offset(IsLeft(dwStyle) ? GetMetrics()->m_cxEdge : 1, GetMetrics()->m_cyEdge * 2);
	}

	// Draw any associated icons.
	pImageList->Draw(pDC, tci.iImage, point, ILD_TRANSPARENT);

	IMAGEINFO info;
	::ZeroMemory(&info, sizeof(info));

	pImageList->GetImageInfo(tci.iImage, &info);
	CRect rcImage(info.rcImage);

	if (IsHorz(dwStyle))
	{
		rcItem.left += rcImage.Width() + GetMetrics()->m_cxEdge;
	}
	else
	{
		rcItem.top += rcImage.Height() + GetMetrics()->m_cyEdge;
	}
}
开发者ID:killbug2004,项目名称:ghost2013,代码行数:59,代码来源:XTPSkinObjectTab.cpp

示例5: SetSortArrow

void CNineShowView::SetSortArrow(CDC *pDC,NineShowData *l_NineShowDat)
{

	int iddd = IDB_1;
	if(!(l_NineShowDat->bAscending)) iddd = IDB_2;
	CImageList list;
	list.Create (iddd,17,1,RGB(255,255,255));
	CPoint p;
	 p.y =(l_NineShowDat->rcTitle.bottom+l_NineShowDat->rcTitle.top)/2-8;
     p.x =l_NineShowDat->rcTitle.right -35;
	list.Draw(pDC,0,p,ILD_TRANSPARENT);
	return;

     CPen *poldpen;
	 CRect rect;

	 CPen pen_white(PS_SOLID,1,RGB(255,255,255));  
	 CPen pen_black(PS_SOLID,1,RGB(0,0,0));     
	 int nBackMode;
     nBackMode=pDC->GetBkMode();
     if(nBackMode==TRANSPARENT) pDC->SetBkMode(OPAQUE);


	 rect.top =(l_NineShowDat->rcTitle.bottom+l_NineShowDat->rcTitle.top)/2-8;
     rect.bottom =(l_NineShowDat->rcTitle.bottom+l_NineShowDat->rcTitle.top)/2+4;
     rect.left =l_NineShowDat->rcTitle.right -17+2;
	 rect.right =l_NineShowDat->rcTitle.right-8+2;


	 poldpen = pDC->SelectObject(&pen_white);
	 if(l_NineShowDat->bAscending)
	 {
		 pDC->MoveTo(rect.left,rect.bottom);
		 pDC->LineTo(rect.right,rect.bottom);
		 pDC->MoveTo(rect.right,rect.bottom);
		 pDC->LineTo((rect.left+rect.right)/2,rect.top);
	 }
	 else
	 {
		 pDC->MoveTo(rect.right,rect.top+4);
		 pDC->LineTo((rect.left+rect.right)/2,rect.bottom+4);
	 }
	 pDC->SelectObject(&pen_black);
     if(l_NineShowDat->bAscending)
	 {
		 pDC->MoveTo(rect.left,rect.bottom);
		 pDC->LineTo((rect.left+rect.right)/2,rect.top);
	 }
	 else
	 {
		 pDC->MoveTo(rect.left,rect.top+4);
		 pDC->LineTo(rect.right,rect.top+4);
		 pDC->MoveTo(rect.left,rect.top+4);
		 pDC->LineTo((rect.left+rect.right)/2,rect.bottom+4);
	 }	 
	 pDC->SelectObject(poldpen);
	 if(nBackMode==TRANSPARENT) pDC->SetBkMode(TRANSPARENT);
} 
开发者ID:ifzz,项目名称:yinhustock,代码行数:58,代码来源:NineShowView.cpp

示例6: DrawItem

void CTabCtrlDoc::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{	
	CRect rect = lpDrawItemStruct->rcItem;
	int nTabIndex = lpDrawItemStruct->itemID;
	if (nTabIndex < 0) return;
	BOOL bSelected = (nTabIndex == GetCurSel());

	WCHAR label[64];
	TC_ITEM tci;
	tci.mask = TCIF_TEXT|TCIF_IMAGE;
	tci.pszText = label;     
	tci.cchTextMax = 63;    	
	if (!GetItem(nTabIndex, &tci)) return;

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (!pDC) return;
	int nSavedDC = pDC->SaveDC();

	// For some bizarre reason the rcItem you get extends above the actual
	// drawing area. We have to workaround this "feature".
	rect.top += ::GetSystemMetrics(SM_CYEDGE);

	pDC->SetBkMode(TRANSPARENT);
	pDC->FillSolidRect(rect, ::GetSysColor(COLOR_BTNFACE));

	// Draw image
	CImageList* pImageList = GetImageList();
	if (pImageList && tci.iImage >= 0) 
	{

		rect.left += pDC->GetTextExtent(_T(" ")).cx;		// Margin

		// Get height of image so we 
		IMAGEINFO info;
		pImageList->GetImageInfo(tci.iImage, &info);
		CRect ImageRect(info.rcImage);
		int nYpos = rect.top;

		pImageList->Draw(pDC, tci.iImage, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
		rect.left += ImageRect.Width();
	}

	if (bSelected) 
	{
		pDC->SetTextColor(m_crSelColour);
		pDC->SelectObject(&m_SelFont);
		rect.top -= ::GetSystemMetrics(SM_CYEDGE);
		pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
	}
	else 
	{
		pDC->SetTextColor(m_crUnselColour);
		pDC->SelectObject(&m_UnselFont);
		pDC->DrawText(label, rect, DT_SINGLELINE|DT_BOTTOM|DT_CENTER);
	}

	pDC->RestoreDC(nSavedDC);
}
开发者ID:alone888,项目名称:fengfang,代码行数:58,代码来源:TabCtrlDoc.cpp

示例7: DrawItem

//显示条目,显示在前部显示驱动其的特征图标
//在其后显示该驱动器的名称
void CDriverBox::DrawItem(LPDRAWITEMSTRUCT lpDS) 
{
	// TODO: Add your code to draw the specified item
	if(lpDS->itemID==LB_ERR) return;
	CDC* pDC=CDC::FromHandle(lpDS->hDC);
	//
	CRect r(lpDS->rcItem);	
	BOOL bEnable=(GetStyle()&WS_DISABLED)==0;
	CImageList list;
	//得到驱动器图标并显示
	list.Create("IDB_DIRBROWNS",16,0,0xffffff);
	r.left+=4;
	list.Draw(pDC,0,r.TopLeft(),bEnable?ILD_TRANSPARENT:ILD_BLEND);	
	r.left+=20;
	CBrush br;
	//绘制字符背景
	if( bEnable&&(/*(lpDS->itemAction & (ODA_SELECT |ODA_SELECT|ODA_FOCUS))
		&&*/(lpDS->itemState & ODS_SELECTED))|
		((lpDS->itemState&ODS_COMBOBOXEDIT)&&(lpDS->itemState&ODS_FOCUS)))
	{   //该条目被选中并被允许
		br.CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));		
		pDC->FillRect(&r, &br);		
		pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
		pDC->SetBkMode(TRANSPARENT);		
		if(lpDS->itemState&ODS_COMBOBOXEDIT)
			pDC->DrawFocusRect(r);
	}		
	else 
	{	br.CreateSolidBrush(GetSysColor(COLOR_WINDOW));
		if(bEnable)pDC->FillRect(&r, &br); 		
		pDC->SetTextColor(GetSysColor(bEnable?COLOR_WINDOWTEXT:COLOR_GRAYTEXT)); 
		pDC->SetBkMode(TRANSPARENT);		
	}
	CString text=m_drvList.GetAt(m_drvList.FindIndex(lpDS->itemID));
	//this->GetItemDataPtr(0);
	//GetLBText(lpDS->itemID,text);

	pDC->TextOut(r.left,r.top,text);
}
开发者ID:hgl888,项目名称:nashtest,代码行数:41,代码来源:DriverBox.cpp

示例8: DrawItem

void CXTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{	
	CRect rect = lpDrawItemStruct->rcItem;
	rect.bottom+=2;
	rect.top += ::GetSystemMetrics(SM_CYEDGE);

	int nTabIndex = lpDrawItemStruct->itemID;
	
	if (nTabIndex < 0) return;

	BOOL bSelected = (nTabIndex == GetCurSel());

	COLORREF crSelected = m_bColorSelected ? m_crSelected : GetSysColor(COLOR_BTNTEXT);
	COLORREF crNormal  = m_bColorNormal   ? m_crNormal   : GetSysColor(COLOR_BTNTEXT);
	COLORREF crDisabled = m_bColorDisabled ? m_crDisabled : GetSysColor(COLOR_GRAYTEXT);


	TCHAR label[64];
	TC_ITEM item;
	item.mask = TCIF_TEXT|TCIF_IMAGE;
	item.pszText = label;     
	item.cchTextMax = 63;    	
	if (!GetItem(nTabIndex, &item))
		return;

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (!pDC)
		return;

	int nSavedDC = pDC->SaveDC();

	CRect rectItem;
	POINT pt;

	GetItemRect(nTabIndex, &rectItem);
	GetCursorPos(&pt);
	ScreenToClient(&pt);

	if (rectItem.PtInRect(pt))
		m_iIndexMouseOver = nTabIndex;



	pDC->SetBkMode(TRANSPARENT);
	pDC->FillSolidRect(rect, ::GetSysColor(COLOR_BTNFACE));

	//**  Draw the image
	CImageList* pImageList = GetImageList();
	if (pImageList && item.iImage >= 0) 
	{

		rect.left += pDC->GetTextExtent(_T(" ")).cx;

		IMAGEINFO info;
		pImageList->GetImageInfo(item.iImage, &info);
		CRect ImageRect(info.rcImage);
		int nYpos = rect.top;

		pImageList->Draw(pDC, item.iImage, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
		rect.left += ImageRect.Width();
	}

	if (!IsTabEnabled(nTabIndex))
	{
		pDC->SetTextColor(crDisabled);
		rect.top -= ::GetSystemMetrics(SM_CYEDGE);
		pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
	}
	else
	{
		//** selected item -----
		if (bSelected)
			pDC->SetTextColor(crSelected);
		else //** other item ---
		{
			if (m_bColorMouseOver && nTabIndex == m_iIndexMouseOver) 
			{
				pDC->SetTextColor(m_crMouseOver);	
			}
			else
			{
				pDC->SetTextColor(crNormal);
			}
		}

		rect.top -= ::GetSystemMetrics(SM_CYEDGE);
		pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);

	}

	pDC->RestoreDC(nSavedDC);
}
开发者ID:corefan,项目名称:nativetaskmanager,代码行数:92,代码来源:XTabCtrl.cpp

示例9: DrawItemEntry

void CXTPSkinObjectHeader::DrawItemEntry(CDC* pDC, int nIndex, CRect rcItem, int nState)
{
	CXTPSkinManagerClass* pClass = GetSkinClass();

	CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*)this;
	CImageList* pImageList = CImageList::FromHandle((HIMAGELIST)
		::SendMessage(pHeaderCtrl->m_hWnd, HDM_GETIMAGELIST, 0, 0L));

	// Set up the header item order array.
	HD_ITEM hdi;
	::ZeroMemory(&hdi, sizeof(HD_ITEM));

	hdi.fmt = HDF_STRING | HDF_IMAGE;
	hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_IMAGE | HDI_LPARAM;

	// Get the header item text and format
	CString strCaption;
	LPTSTR pszText = strCaption.GetBuffer(256);
	pszText[0] = 0;
	hdi.pszText = pszText;
	hdi.cchTextMax = 255;

	BOOL bResult = pHeaderCtrl->GetItem(nIndex, &hdi);

	strCaption.ReleaseBuffer();

#ifdef _UNICODE
	if (!bResult)
	{
		char tText[256];
		tText[0] = 0;

		HD_ITEMA hdia;
		::ZeroMemory(&hdia, sizeof(HD_ITEMA));

		hdia.fmt = HDF_STRING | HDF_IMAGE;
		hdia.mask = HDI_TEXT | HDI_FORMAT | HDI_IMAGE | HDI_LPARAM;

		// Get the header item text and format
		hdia.pszText = tText;
		hdia.cchTextMax = 255;

		::SendMessage(pHeaderCtrl->m_hWnd, HDM_GETITEMA, nIndex, (LPARAM)&hdia);

		strCaption = tText;
		hdi.fmt = hdia.fmt;
		hdi.iImage = hdia.iImage;
		hdi.lParam = hdia.lParam;
	}
#else
	bResult;
#endif

	if (hdi.fmt & HDF_OWNERDRAW)
	{
		DRAWITEMSTRUCT dis;

		dis.CtlType = ODT_HEADER;
		dis.CtlID = (UINT)GetDlgCtrlID();
		dis.itemID = nIndex;
		dis.itemAction = ODA_DRAWENTIRE;
		dis.itemState = (nState == HIS_PRESSED) ? ODS_SELECTED : 0;
		dis.hwndItem = m_hWnd;
		dis.hDC = pDC->GetSafeHdc();
		dis.rcItem = rcItem;
		dis.itemData = hdi.lParam;

		// Now send it off to my parent...
		if (GetParent()->SendMessage(WM_DRAWITEM, dis.CtlID,
			(LPARAM)(DRAWITEMSTRUCT*)&dis))
		{
			return;
		}
	}

	CRect rcText(rcItem);

	if (pImageList && (hdi.fmt & HDF_IMAGE) && hdi.iImage >= 0 && hdi.iImage < pImageList->GetImageCount())
	{
		int iBitmapMargin = (int)SendMessage(HDM_GETBITMAPMARGIN);
		if (iBitmapMargin == 0)
			iBitmapMargin = GetMetrics()->m_cxEdge * 3;
		int cxBitmap = 16, cyBitmap = 16;
		ImageList_GetIconSize(pImageList->GetSafeHandle(), &cxBitmap, &cyBitmap);

		CPoint pt(rcItem.left + iBitmapMargin, (rcItem.bottom + rcItem.top - cyBitmap) / 2);

		if (hdi.fmt & HDF_BITMAP_ON_RIGHT)
		{
			CSize sz = pDC->GetTextExtent(strCaption);

			pt.x += sz.cx + iBitmapMargin + 9;
			if (pt.x + cxBitmap > rcItem.right - 3)
				pt.x = max(rcItem.left + 6, rcItem.right - 3 - cxBitmap);
			if (nState == HIS_PRESSED)
				pt.x ++;

			pImageList->Draw(pDC, hdi.iImage, pt, ILD_TRANSPARENT);
			rcText.right = pt.x + 6;
		}
//.........这里部分代码省略.........
开发者ID:lai3d,项目名称:ThisIsASoftRenderer,代码行数:101,代码来源:XTPSkinObjectHeader.cpp

示例10: DrawItem

void CEnListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC;
	CRect rText, rItem, rClient, rHeader;
	COLORREF crOldText, crOldBack;
	CSize sizeText;
	LV_COLUMN lvc = { 0 };
//	CPen* pOldPen;
	CImageList* pImageList;
	CImageList* pStateList;
	int nImage = -1;
	BOOL bItemFocused, bListFocused, bSelected, bDropHighlighted, bSelAlways;
	UINT uStyle, uState;
	CSize sizeState(0, 0), sizeImage(0, 0);
	int nIndent = 0;

	// get and prepare device context
	pDC = CDC::FromHandle(lpDrawItemStruct->hDC);//GetDC(); 
	pDC->SelectObject(GetFont());
	pDC->SetROP2(R2_COPYPEN);

	// init helper variables
	int nItem = lpDrawItemStruct->itemID;
	GetItemRect(nItem, rItem, LVIR_BOUNDS);//lpDrawItemStruct->rcItem;
	GetClientRect(&rClient);

	// some problems with drophiliting items during drag and drop
	// so we need to make sure drawing is clipped to client area
	// this fixes it admirably!
	if (GetHeader())
	{
		GetHeader()->GetWindowRect(rHeader);
		ScreenToClient(rHeader);
		rClient.top = max(0, rHeader.bottom);
		pDC->IntersectClipRect(rClient);
	}

	rText = rItem;

	uStyle = GetStyle();
	uState = GetItemState(nItem, LVIS_DROPHILITED | LVIS_SELECTED);
	bDropHighlighted = (uState & LVIS_DROPHILITED);
	bItemFocused = (GetFocusedItem() == nItem);
	bListFocused = (GetFocus() == this);
	bSelected = (uState & LVIS_SELECTED);
	bSelAlways = ((uStyle & LVS_SHOWSELALWAYS) == LVS_SHOWSELALWAYS);
	bSelected = bSelected && (bListFocused || bSelAlways);

	crOldText = pDC->SetTextColor(COLORREF(0)); // this will be overwritten on a per subitem basis
	crOldBack = pDC->SetBkColor(GetItemBackColor(nItem, bSelected, bDropHighlighted, bListFocused));

	// images and indentation
	pImageList = GetImageList(LVSIL_SMALL);

	if (pImageList)
	{
		nImage = GetImageIndex(nItem, 0); 
		ImageList_GetIconSize(pImageList->m_hImageList, (int*)&sizeImage.cx, (int*)&sizeImage.cy);

		nIndent = GetItemIndent(nItem) * sizeImage.cx;

		rText.left += nIndent;
		rItem.left += nIndent;

//		if (pImageList == &s_ilIndent)
//			pImageList = NULL;
	}

	// state
	pStateList = GetImageList(LVSIL_STATE);

	if (pStateList)
		ImageList_GetIconSize(pStateList->m_hImageList, (int*)&sizeState.cx, (int*)&sizeState.cy);

	if (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT))
	{
		// setup colors and pens
		int nImageStyle = GetImageStyle(bSelected, bDropHighlighted, bListFocused);

		// draw item images if required
		int nImageWidth = 0;

		// make sure there is enough space
		lvc.mask = LVCF_WIDTH | LVCF_FMT;
		int nCol = 0;
		BOOL bRes = GetColumn(nCol, &lvc);
		
		// must paint the background of column 0 before the icons
		if (bRes && (pStateList || pImageList))
			pDC->ExtTextOut(0, rItem.top, ETO_CLIPPED | ETO_OPAQUE, CRect(0, rItem.top, lvc.cx, rItem.bottom), _T(""), NULL);

		// state
		if (pStateList && bRes)
		{
			int nState = (GetItemState(nItem, LVIS_STATEIMAGEMASK) & LVIS_STATEIMAGEMASK);
			nState = nState >> 12;

			if (lvc.cx > sizeState.cx)
				pStateList->Draw(pDC, nState, CPoint(rText.left + 1, rText.top), ILD_TRANSPARENT); 

//.........这里部分代码省略.........
开发者ID:jithuin,项目名称:infogeezer,代码行数:101,代码来源:enlistctrl.cpp

示例11: DrawItem

void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDraw)
{try{
	int cCols = GetHeaderCtrl ()->GetItemCount ();
	CDC *dc = CDC::FromHandle (lpDraw->hDC);
	int xStart = lpDraw->rcItem.left;	
	CImageList *pImages = GetImageList (LVSIL_SMALL);
	BOOL bNeedBorder = FALSE;	

	

	CHeaderCtrl* pHdr = GetHeaderCtrl ();

	
	for (int i = 0; i < cCols; i++)
	{
		LVITEM item;
		TCHAR szItem [10000];
		int colWidth = GetColumnWidth (pHdr->OrderToIndex (i));

		xStart += 5;
		colWidth -= 5;

		item.iItem = lpDraw->itemID;
		item.iSubItem = i;
		item.pszText = szItem;
		item.cchTextMax = sizeof (szItem);
		item.mask = LVIF_IMAGE | LVIF_TEXT;

		GetItem (&item);

		
		if (i == 0)
		{
			item.state = GetItemState (lpDraw->itemID, LVIS_SELECTED|LVIS_FOCUSED);

			COLORREF clrBg = m_vInfo [lpDraw->itemID].clrBg;
			COLORREF clrText = m_vInfo [lpDraw->itemID].clrText;
	
			
			
			if (item.state & LVIS_FOCUSED)
				bNeedBorder = TRUE;

			if (item.state & LVIS_SELECTED)
			{
				clrBg = GetSysColor (COLOR_HIGHLIGHT);
				clrText = GetSysColor (COLOR_HIGHLIGHTTEXT);
				if (bNeedBorder == FALSE)
				{
					if (GetSelectionMark () == (int)lpDraw->itemID)
						bNeedBorder = TRUE;
				}
			}
		
			CBrush br;
			CPen pen;
			CBrush *oldBr;
			CPen *oldPen;

			if (RGBIsEqual (clrBg, clrText))
				clrText = (~clrText) & 0x00FFFFFF;

			dc->SetTextColor (clrText);

			br.CreateSolidBrush (clrBg);
			pen.CreatePen (PS_SOLID, 1, clrBg);

			oldBr = dc->SelectObject (&br);
			oldPen = dc->SelectObject (&pen);
			
			dc->Rectangle (&lpDraw->rcItem);

			
			if (m_bGrid)
			{
				CPen pen1 (PS_SOLID, 1, m_clrGrid);
				dc->SelectObject (&pen1);
				dc->MoveTo (lpDraw->rcItem.left, lpDraw->rcItem.bottom-1);
				dc->LineTo (lpDraw->rcItem.right, lpDraw->rcItem.bottom-1);
				dc->SelectObject (oldPen);
			}

			dc->SelectObject (oldBr);
			dc->SelectObject (oldPen);

			if (pImages)
			{
				

				CPoint pt;
				pt.x = xStart;
				pt.y = lpDraw->rcItem.top;
				if (m_pSelImages && (item.state & LVIS_SELECTED))
					m_pSelImages->Draw (dc, item.iImage, pt, ILD_TRANSPARENT);
				else
					pImages->Draw (dc, item.iImage, pt, ILD_TRANSPARENT);

				IMAGEINFO inf;
				pImages->GetImageInfo (item.iImage, &inf);

//.........这里部分代码省略.........
开发者ID:HackLinux,项目名称:Free-Download-Manager-vs2010,代码行数:101,代码来源:ListCtrlEx.cpp

示例12: CreateDragImageEx

CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
{
    if (GetSelectedCount() <= 0) {
        return nullptr;
    }

    CRect cSingleRect, cCompleteRect(0, 0, 0, 0);
    GetClientRect(cSingleRect);
    int nWidth = cSingleRect.Width();

    // Start and Stop index in view area
    int nIndex = GetTopIndex() - 1;
    int nBottomIndex = GetBottomIndex();

    // Determine the size of the drag image (limited for
    // rows visible and Client width)
    while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
        GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
        /*
        CRect r;
        GetItemRect(nIndex, r, LVIR_LABEL);
        cSingleRect.left = r.left;
        */
        if (cSingleRect.left < 0) {
            cSingleRect.left = 0;
        }
        if (cSingleRect.right > nWidth) {
            cSingleRect.right = nWidth;
        }

        cCompleteRect |= cSingleRect;
    }

    //
    // Create bitmap in memory DC
    //
    CClientDC cDc(this);
    CDC cMemDC;
    CBitmap cBitmap;

    if (!cMemDC.CreateCompatibleDC(&cDc)) {
        return nullptr;
    }

    if (!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height())) {
        return nullptr;
    }

    CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
    // Here green is used as mask color
    cMemDC.FillSolidRect(0, 0, cCompleteRect.Width(), cCompleteRect.Height(), RGB(0, 255, 0));

    // Paint each DragImage in the DC
    nIndex = GetTopIndex() - 1;
    while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
        CPoint pt;
        CImageList* pSingleImageList = CreateDragImage(nIndex, &pt);

        if (pSingleImageList) {
            GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);

            pSingleImageList->Draw(&cMemDC,
                                   0,
                                   CPoint(cSingleRect.left - cCompleteRect.left, cSingleRect.top - cCompleteRect.top),
                                   ILD_MASK);

            pSingleImageList->DeleteImageList();
            delete pSingleImageList;
        }
    }

    cMemDC.SelectObject(pOldMemDCBitmap);

    //
    // Create the image list with the merged drag images
    //
    CImageList* pCompleteImageList = DEBUG_NEW CImageList;

    pCompleteImageList->Create(cCompleteRect.Width(),
                               cCompleteRect.Height(),
                               ILC_COLOR | ILC_MASK, 0, 1);

    // Here green is used as mask color
    pCompleteImageList->Add(&cBitmap, RGB(0, 255, 0));

    //
    // as an optional service:
    // Find the offset of the current mouse cursor to the image list
    // this we can use in BeginDrag()
    //
    if (lpPoint) {
        lpPoint->x = cCompleteRect.left;
        lpPoint->y = cCompleteRect.top;
    }

    return pCompleteImageList;
}
开发者ID:Chris-Hood,项目名称:mpc-hc,代码行数:97,代码来源:PlayerListCtrl.cpp

示例13: drawItemImage

void CNOutBarCtrl::drawItemImage(CDC *pDC, int i, CRect &rc)
{
	int img = folders[selFolder]->items[i]->image;
	CImageList *imageList = (largeIconView ? largeIcons : smallIcons);
	imageList->Draw(pDC, img, rc.TopLeft(), ILD_TRANSPARENT);
}
开发者ID:BackupTheBerlios,项目名称:sfsipua-svn,代码行数:6,代码来源:OutBarCtrl.cpp

示例14: DrawItem

void CListCtrlEx::DrawItem(_In_ LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); 

	LVITEM lvi = {0}; 
	lvi.mask = LVIF_STATE|LVIF_IMAGE; 
	lvi.stateMask = LVIS_FOCUSED | LVIS_SELECTED ; 
	lvi.iItem = lpDrawItemStruct->itemID; 
	BOOL bGet = GetItem(&lvi); 

	BOOL bHighlight =((lvi.state & LVIS_DROPHILITED)||((lvi.state & LVIS_SELECTED) && 
		((GetFocus() == this)|| (GetStyle() & LVS_SHOWSELALWAYS)))); 

	// 画文本背景 
	CRect rcBack = lpDrawItemStruct->rcItem; 
	pDC->SetBkMode(TRANSPARENT); 
	if( lpDrawItemStruct->itemState&ODS_SELECTED && lvi.state & LVIS_SELECTED) //如果被选择
	{ 
		COLORREF ref=RGB(0,0,0);
		pDC->SetTextColor(ref); 
		pDC->SetBkColor(ref); 

		pDC->FillRect(rcBack, &CBrush(RGB( 0xff, 0xe4, 0x91 )/*0xEEDED4*/));
	} 
	else 
	{ 

		pDC->SetTextColor(RGB(0,0,0)); 
		pDC->FillRect(rcBack, &CBrush(0xFFFFFF/*0xEEF1E3*/));
	} 

	//设置字体颜色 
	CString str; 

	//得到焦点大小 
	CRect rcFocus = lpDrawItemStruct->rcItem; 
	rcFocus.DeflateRect(1,1,1,1); 

	INT nColumnCount = GetHeaderCtrl()->GetItemCount();

	if (lpDrawItemStruct->itemAction & ODA_DRAWENTIRE) 
	{ 
		LOGFONT lf;
		pDC->GetCurrentFont()->GetLogFont(&lf);

		lf.lfCharSet = GB2312_CHARSET;
		lf.lfHeight = 12;
		lf.lfWidth  = 0;
		lf.lfWeight = FW_NORMAL;
		strcpy_s(lf.lfFaceName,"宋体");

		CFont font;
		font.CreateFontIndirect(&lf);
		CFont *pOldFont = pDC->SelectObject(&font);

		//写文本 
		CString szText; 
		CSize si;
		for (int i = 0; i <nColumnCount; i++) 
		{ //循环得到文本 
			CRect rcItem; 
			if ( !GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_LABEL, rcItem )) 
				continue; 
			szText = GetItemText( lpDrawItemStruct->itemID, i ); 

			si = pDC->GetTextExtent(szText);
			rcItem.left += 5; rcItem.right -= 1;
			rcItem.top = (rcItem.bottom  + rcItem.top - si.cy)/2;
			pDC->DrawText(szText/*szText*/, lstrlen(szText), &rcItem, DT_NOPREFIX|DT_SINGLELINE); 
		}

		pDC->SelectObject(pOldFont);

		CImageList * pImageList = GetImageList(LVSIL_SMALL);
		if (pImageList)
		{
			CRect rcItem; 
			if (GetSubItemRect(lpDrawItemStruct->itemID,0, LVIR_ICON, rcItem ))
			{
				rcItem.top += 3;
				pImageList->Draw(pDC,lvi.iImage,rcItem.TopLeft(),TVSIL_NORMAL); // 在行首绘制图标
			}
		}
	} 
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:85,代码来源:VirtualList.cpp

示例15: DrawItem

void CTabCtrlEx::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    if(lpDrawItemStruct->CtlType == ODT_TAB)
    {
        CRect rect = lpDrawItemStruct->rcItem;
        INT nTabIndex = lpDrawItemStruct->itemID;
        if (nTabIndex < 0) return;

        TCHAR label[64];
        TC_ITEM tci;
        tci.mask = TCIF_TEXT|TCIF_IMAGE;
        tci.pszText = label;
        tci.cchTextMax = 63;
        GetItem(nTabIndex, &tci );

        CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
        if (!pDC) return;
        int nSavedDC = pDC->SaveDC();

        //填充背景色
        COLORREF rcBack;
        if (lpDrawItemStruct->itemState & CDIS_SELECTED  )
            rcBack = RGB(255, 255,255);
        else if(lpDrawItemStruct->itemState & (CDIS_DISABLED | CDIS_GRAYED) )
            rcBack = RGB(0, 255, 0);
        else
            rcBack = GetSysColor(COLOR_BTNFACE);
        pDC->FillSolidRect(rect, rcBack);

        rect.top += ::GetSystemMetrics(SM_CYEDGE);

        pDC->SetBkMode(TRANSPARENT);

        //绘制图片
        CImageList *pImageList = GetImageList();
        if (pImageList && tci.iImage >= 0)
        {
            rect.left += pDC->GetTextExtent(_T(" ")).cx;       // Margin

            // Get height of image so we
            IMAGEINFO info;
            pImageList->GetImageInfo(tci.iImage, &info);
            CRect ImageRect(info.rcImage);
            INT nYpos = rect.top;

            pImageList->Draw(pDC, tci.iImage, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
            rect.left += ImageRect.Width();
        }

        //绘制字体
        COLORREF txtColor;
        if (lpDrawItemStruct->itemState & CDIS_SELECTED  )
        {
            rect.top -= ::GetSystemMetrics(SM_CYEDGE);

            txtColor = RGB(0,0,255);
        }
        else if(lpDrawItemStruct->itemState & (CDIS_DISABLED | CDIS_GRAYED) )
            txtColor = RGB(128, 128, 128);
        else
            txtColor = GetSysColor(COLOR_WINDOWTEXT);
        pDC->SetTextColor(txtColor);
		int r=rect.right;
		rect.right-=15;
        pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
		rect.right=r;
		rect.left=rect.right-17;
		rect.top+=3;
		rect.bottom-=6;
		pDC->DrawFrameControl(&rect,DFCS_CAPTIONCLOSE,DFCS_BUTTONPUSH);
        pDC->RestoreDC(nSavedDC);

    }
}
开发者ID:myosg,项目名称:MyOsgMfcTest,代码行数:74,代码来源:TabCtrlEx.cpp


注:本文中的CImageList::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。