本文整理汇总了C++中CImageList::DrawIndirect方法的典型用法代码示例。如果您正苦于以下问题:C++ CImageList::DrawIndirect方法的具体用法?C++ CImageList::DrawIndirect怎么用?C++ CImageList::DrawIndirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImageList
的用法示例。
在下文中一共展示了CImageList::DrawIndirect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawImage
INT CFlatHeaderCtrl::DrawImage(CDC* pDC, CRect rect, LPHDITEM lphdi, BOOL bRight)
{
CImageList* pImageList = GetImageList();
INT iWidth = 0;
if(lphdi->mask&HDI_IMAGE && lphdi->fmt&HDF_IMAGE)
{
ASSERT(pImageList);
ASSERT(lphdi->iImage>=0 && lphdi->iImage<pImageList->GetImageCount());
if(rect.Width()>0)
{
POINT point;
point.y = rect.CenterPoint().y - (m_sizeImage.cy>>1);
if(bRight)
point.x = rect.right - m_sizeImage.cx;
else
point.x = rect.left;
SIZE size;
size.cx = rect.Width()<m_sizeImage.cx ? rect.Width():m_sizeImage.cx;
size.cy = m_sizeImage.cy;
pImageList->DrawIndirect(pDC, lphdi->iImage, point, size, CPoint(0, 0));
iWidth = m_sizeImage.cx;
}
示例2: DrawSortImage
int CSHeaderCtrl::DrawSortImage(CDC* pDC, const CRect& rect, LPHDITEM lphdi)
{
int iWidth = 0;
if (rect.Width() > 0)
{
UINT nSortIndex = SHC_STATE_TO_INDEX_SORT(lphdi->iImage);
CImageList* pImageList = GetImageList();
if(nSortIndex != SHC_NONE_SORT && pImageList != NULL)
{
POINT point;
point.y = rect.CenterPoint().y - ((m_sizeImage.cy+1) >> 1);
point.x = rect.left;
SIZE size;
size.cx = rect.Width() < m_sizeImage.cx ? rect.Width() : m_sizeImage.cx;
size.cy = m_sizeImage.cy;
// save image list background color
COLORREF rgb = pImageList->GetBkColor();
// set image list background color to same as header control
pImageList->DrawIndirect(pDC, GetIndexOfImageList(nSortIndex), point, size, CPoint(0, 0));
iWidth = size.cx;
}
示例3: GetBMPfromList
/************************************************************************
getBitmapFromImagelist 이미지 리스트로 부터 단일 오브젝트를 추출한다.
@param :
@return :
@remark :
http://www.codeproject.com/bitmap/getimagefromlist.asp
@author : youngchang ([email protected])
@history:
2005/12/16:CREATED
************************************************************************/
void CFishBMPManager::GetBMPfromList(CDC* pDC, CImageList *lstImages, int nImage, CBitmap* destBitmap)
{
destBitmap->DeleteObject();
CImageList tmpList;
tmpList.Create(lstImages);
tmpList.Copy( 0, nImage, ILCF_SWAP );
IMAGEINFO lastImage;
tmpList.GetImageInfo(0,&lastImage);
CDC dcMem;
dcMem.CreateCompatibleDC (pDC);
CRect rect (lastImage.rcImage);
destBitmap->CreateCompatibleBitmap (pDC, rect.Width (), rect.Height ());
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);
tmpList.DrawIndirect (&dcMem, 0, CPoint (0, 0), CSize (rect.Width (), rect.Height ()), CPoint (0, 0));
dcMem.SelectObject (pBmpOld);
}
示例4: DrawImage
///////////////////////////////////////////////////////////////////////////////
// DrawImage
int CXHeaderCtrl::DrawImage(CDC* pDC, CRect rect, LPHDITEM lphdi, BOOL bRight)
{
CImageList* pImageList = GetImageList();
int iWidth = 0;
if (lphdi->iImage != XHEADERCTRL_NO_IMAGE)
{
if (pImageList)
{
if (rect.Width() > 0)
{
POINT point;
point.y = rect.CenterPoint().y - (m_sizeImage.cy >> 1);
if (bRight)
point.x = rect.right - m_sizeImage.cx;
else
point.x = rect.left;
SIZE size;
size.cx = rect.Width()<m_sizeImage.cx ? rect.Width():m_sizeImage.cx;
size.cy = m_sizeImage.cy;
// save image list background color
COLORREF rgb = pImageList->GetBkColor();
// set image list background color to same as header control
pImageList->SetBkColor(pDC->GetBkColor());
pImageList->DrawIndirect(pDC, lphdi->iImage, point, size, CPoint(0, 0));
pImageList->SetBkColor(rgb);
iWidth = m_sizeImage.cx;
}
}
}
示例5: CreateDragImageEx
// Based on code by Frank Kobs.
CImageList* CDragDropListCtrl::CreateDragImageEx(LPPOINT lpPoint)
{
CRect rectSingle;
CRect rectComplete(0, 0, 0, 0);
int nIndex = -1;
BOOL bFirst = TRUE;
// Determine the size of the drag image.
POSITION pos = GetFirstSelectedItemPosition();
while (pos)
{
nIndex = GetNextSelectedItem(pos);
GetItemRect(nIndex, rectSingle, LVIR_BOUNDS);
if (bFirst)
{
// Initialize the CompleteRect
GetItemRect(nIndex, rectComplete, LVIR_BOUNDS);
bFirst = FALSE;
}
rectComplete.UnionRect(rectComplete, rectSingle);
}
// Create bitmap in memory DC
CClientDC dcClient(this);
CDC dcMem;
CBitmap Bitmap;
if (!dcMem.CreateCompatibleDC(&dcClient))
{
return NULL;
}
if (!Bitmap.CreateCompatibleBitmap(&dcClient, rectComplete.Width(), rectComplete.Height()))
{
return NULL;
}
CBitmap* pOldMemDCBitmap = dcMem.SelectObject(&Bitmap);
// Here green is used as mask color.
dcMem.FillSolidRect(0, 0, rectComplete.Width(), rectComplete.Height(), RGB(0, 255, 0));
// Paint each DragImage in the DC.
CImageList* pSingleImageList = NULL;
CPoint pt;
pos = GetFirstSelectedItemPosition();
while (pos)
{
nIndex = GetNextSelectedItem(pos);
GetItemRect(nIndex, rectSingle, LVIR_BOUNDS);
pSingleImageList = CreateDragImage(nIndex, &pt);
if (pSingleImageList)
{
// Make sure width takes into account not using LVS_EX_FULLROWSELECT style.
IMAGEINFO ImageInfo;
pSingleImageList->GetImageInfo(0, &ImageInfo);
rectSingle.right = rectSingle.left + (ImageInfo.rcImage.right - ImageInfo.rcImage.left);
pSingleImageList->DrawIndirect(
&dcMem,
0,
CPoint(rectSingle.left - rectComplete.left,
rectSingle.top - rectComplete.top),
rectSingle.Size(),
CPoint(0,0));
delete pSingleImageList;
}
}
dcMem.SelectObject(pOldMemDCBitmap);
// Create the imagelist with the merged drag images.
CImageList* pCompleteImageList = new CImageList;
pCompleteImageList->Create(rectComplete.Width(), rectComplete.Height(), ILC_COLOR | ILC_MASK, 0, 1);
// Here green is used as mask color.
pCompleteImageList->Add(&Bitmap, RGB(0, 255, 0));
Bitmap.DeleteObject();
// As an optional service:
// Find the offset of the current mouse cursor to the imagelist
// this we can use in BeginDrag().
if (lpPoint)
{
CPoint ptCursor;
GetCursorPos(&ptCursor);
ScreenToClient(&ptCursor);
lpPoint->x = ptCursor.x - rectComplete.left;
lpPoint->y = ptCursor.y - rectComplete.top;
}
return pCompleteImageList;
}
示例6: OnCustomdrawList
/////////////////////////////////////////////////////////////////////////////
// handle custom drawing
/////////////////////////////////////////////////////////////////////////////
void CCustomListCtrl::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
int nItem;
CSize sizeSpacing;
CDC *pDC;
CRect rect;
CImageList *pImage;
COLORREF color;
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
if(CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
{
GetClientRect(&rect);
//get device context
pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
//clear background
pDC->FillSolidRect(&rect, COLOR_BLACK);
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if(CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
{
//get the image list
pImage = GetImageList(LVSIL_NORMAL);
//get the item
nItem = pLVCD->nmcd.dwItemSpec;
//get the item spacing
sizeSpacing = SetIconSpacing(0, 0);
SetIconSpacing(sizeSpacing);
//get device context
pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
//get the item rect
GetItemRect(nItem, &rect, LVIR_ICON);
//set normal color
color = TAB_COLOR_BACKGROUND;
//offset the rect if needed
if(LIST_CHIT_SPACING == m_nIconSize)
{
rect.OffsetRect(3, 0);
}
//fill selection background
if(nItem == m_nSelection)
{
//get highlight color
color = ::GetSysColor(COLOR_HIGHLIGHT);
//fill it with the selected color
pDC->FillSolidRect(&rect, color);
}
//offset the rect if needed
if(LIST_CHIT_SPACING == m_nIconSize)
{
rect.OffsetRect(-3, 0);
}
//now draw the item
if(NULL != pImage)
{
pImage->DrawIndirect(pDC, nItem, CPoint(rect.left + 4, rect.top + 2), CSize(32, 32), CPoint(0, 0));
}
// Tell Windows to paint the control itself.
*pResult = CDRF_SKIPDEFAULT;
}
}