本文整理汇总了C++中CImageList::GetImageInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ CImageList::GetImageInfo方法的具体用法?C++ CImageList::GetImageInfo怎么用?C++ CImageList::GetImageInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImageList
的用法示例。
在下文中一共展示了CImageList::GetImageInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: 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;
}
}
示例4: 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);
}
示例5: OnSetImageList
LRESULT CSHeaderCtrl::OnSetImageList(WPARAM, LPARAM lParam)
{
CImageList* pImageList;
pImageList = CImageList::FromHandle((HIMAGELIST)lParam);
IMAGEINFO info;
if (pImageList->GetImageInfo(0, &info))
{
m_sizeImage.cx = info.rcImage.right - info.rcImage.left;
m_sizeImage.cy = info.rcImage.bottom - info.rcImage.top;
}
return Default();
}
示例6: 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);
}
示例7: Py_BuildValue
// @pymethod iiii(iiii)|PyCImageList|GetImageInfo|Retrieves information about an image.
PyObject *PyCImageList_GetImageInfo( PyObject *self, PyObject *args )
{
CImageList *pList;
int nIndex;
if (!(pList=PyCImageList::GetImageList(self)))
return NULL;
// @pyparm int|index||Index of image.
if (!PyArg_ParseTuple(args, "i:GetImageInfo", &nIndex))
return NULL;
IMAGEINFO info;
GUI_BGN_SAVE;
BOOL ok = pList->GetImageInfo(nIndex, &info);
GUI_END_SAVE;
if (!ok)
RETURN_ERR("GetImageInfo failed");
return Py_BuildValue("iiii(iiii)", info.hbmImage, info.hbmMask,
info.Unused1, info.Unused2,
info.rcImage.left,info.rcImage.top,info.rcImage.right,info.rcImage.bottom );
// @rdesc The return info is a tuple describing an IMAGELIST structure.
}
示例8: ResizeAllListCtrlCols
void CCommonAppUtils::ResizeAllListCtrlCols(CListCtrl * pListCtrl)
{
int maxcol = ((CHeaderCtrl*)(pListCtrl->GetDlgItem(0)))->GetItemCount()-1;
int nItemCount = pListCtrl->GetItemCount();
TCHAR textbuf[MAX_PATH] = { 0 };
CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(pListCtrl->GetDlgItem(0));
if (pHdrCtrl)
{
int imgWidth = 0;
CImageList * pImgList = pListCtrl->GetImageList(LVSIL_SMALL);
if ((pImgList)&&(pImgList->GetImageCount()))
{
IMAGEINFO imginfo;
pImgList->GetImageInfo(0, &imginfo);
imgWidth = (imginfo.rcImage.right - imginfo.rcImage.left) + 3; // 3 pixels between icon and text
}
for (int col = 0; col <= maxcol; col++)
{
HDITEM hdi = {0};
hdi.mask = HDI_TEXT;
hdi.pszText = textbuf;
hdi.cchTextMax = _countof(textbuf);
pHdrCtrl->GetItem(col, &hdi);
int cx = pListCtrl->GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
for (int index = 0; index<nItemCount; ++index)
{
// get the width of the string and add 14 pixels for the column separator and margins
int linewidth = pListCtrl->GetStringWidth(pListCtrl->GetItemText(index, col)) + 14;
// add the image size
if (col == 0)
linewidth += imgWidth;
if (cx < linewidth)
cx = linewidth;
}
pListCtrl->SetColumnWidth(col, cx);
}
}
}
示例9: DrawItem
//.........这里部分代码省略.........
if (nTabIndex == GetItemCount() - 1)
iPartId = TABP_TABITEMBOTHEDGE; // First & Last item
else
iPartId = TABP_TABITEMLEFTEDGE;
}
else if (nTabIndex == GetItemCount() - 1) {
// Last item
iPartId = TABP_TABITEMRIGHTEDGE;
}
else {
iPartId = TABP_TABITEM;
}
}
if (g_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
g_xpStyle.DrawThemeParentBackground(m_hWnd, *pDC, &rcFullItem);
g_xpStyle.DrawThemeBackground(hTheme, *pDC, iPartId, iStateId, &rcBk, NULL);
}
}
// Following background clearing is needed for:
// WinXP/Vista (when used without an application theme)
// Vista (when used with an application theme but without a theme for the tab control)
if ( (!g_xpStyle.IsThemeActive() || !g_xpStyle.IsAppThemed())
|| (hTheme == NULL && bVistaThemeActive) )
pDC->FillSolidRect(&lpDIS->rcItem, GetSysColor(COLOR_BTNFACE));
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(nTabIndex, rect, rcCloseButton, bSelected, bVistaThemeActive);
HTHEME hThemeNC = bVistaThemeActive ? g_xpStyle.OpenThemeData(m_hWnd, _T("WINDOW")) : NULL;
if (hThemeNC) {
// Possible "Close" parts: WP_CLOSEBUTTON, WP_SMALLCLOSEBUTTON, WP_MDICLOSEBUTTON
int iPartId = WP_SMALLCLOSEBUTTON;
int iStateId = (bSelected || bVistaHotTracked) ? CBS_NORMAL : CBS_DISABLED;
if (g_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
g_xpStyle.DrawThemeParentBackground(m_hWnd, *pDC, &rcCloseButton);
g_xpStyle.DrawThemeBackground(hThemeNC, *pDC, iPartId, iStateId, rcCloseButton, NULL);
g_xpStyle.CloseThemeData(hThemeNC);
}
else {
m_ImgLstCloseButton.Draw(pDC, (bSelected || bVistaHotTracked) ? 0 : 1, rcCloseButton.TopLeft(), ILD_TRANSPARENT);
}
rect.right = rcCloseButton.left - 2;
示例10: AppendStateImages
//------------------------------------------------------------------------
//! Appends the checkbox state images to the list control image list
//!
//! @param owner The list control adding column
//! @param imagelist The image list assigned to the list control
//! @return Image index where the two state images (unchecked/checked) was inserted
//------------------------------------------------------------------------
int CGridColumnTraitImage::AppendStateImages(CGridListCtrlEx& owner, CImageList& imagelist)
{
if (!(owner.GetExtendedStyle() & LVS_EX_SUBITEMIMAGES))
owner.SetExtendedStyle(owner.GetExtendedStyle() | LVS_EX_SUBITEMIMAGES);
if (!imagelist)
imagelist.Create(16, 16, ILC_COLOR16 | ILC_MASK, 1, 0);
if (!owner.GetImageList(LVSIL_SMALL))
owner.SetImageList(&imagelist, LVSIL_SMALL);
VERIFY(owner.GetImageList(LVSIL_SMALL) == &imagelist);
bool createdStateImages = false;
CImageList* pStateList = owner.GetImageList(LVSIL_STATE);
if (pStateList == NULL)
{
if (!(owner.GetExtendedStyle() & LVS_EX_CHECKBOXES))
{
createdStateImages = true;
owner.SetExtendedStyle(owner.GetExtendedStyle() | LVS_EX_CHECKBOXES);
pStateList = owner.GetImageList(LVSIL_STATE);
}
}
int imageCount = -1;
ASSERT(pStateList != NULL);
if (pStateList != NULL && pStateList->GetImageCount() >= 2)
{
imageCount = imagelist.GetImageCount();
// Get the icon size of current imagelist
CSize iconSize(16, 16);
if (imageCount > 0)
{
IMAGEINFO iconSizeInfo = { 0 };
VERIFY(imagelist.GetImageInfo(0, &iconSizeInfo));
iconSize =
CSize(iconSizeInfo.rcImage.right - iconSizeInfo.rcImage.left,
iconSizeInfo.rcImage.bottom - iconSizeInfo.rcImage.top);
}
// Scale the icon-position if necessary
CPoint iconPos(1, 0); // +1 pixel to avoid overlap with left-grid-line
{
IMAGEINFO stateSizeInfo = { 0 };
VERIFY(pStateList->GetImageInfo(0, &stateSizeInfo));
int stateIconHeight = stateSizeInfo.rcImage.bottom - stateSizeInfo.rcImage.top;
if (iconSize.cy > stateIconHeight)
iconPos.y = (iconSize.cy - stateIconHeight) / 2;
}
// Redraw the state-icon to match the icon size of the current imagelist (without scaling image)
CClientDC clienDC(&owner);
CDC memDC;
VERIFY(memDC.CreateCompatibleDC(&clienDC));
CBitmap dstBmp;
VERIFY(dstBmp.CreateCompatibleBitmap(&clienDC, iconSize.cx, iconSize.cy));
CBitmap* pBmpOld = memDC.SelectObject(&dstBmp);
COLORREF oldBkColor = pStateList->SetBkColor(imagelist.GetBkColor());
CBrush brush(imagelist.GetBkColor());
memDC.FillRect(CRect(0, 0, iconSize.cx, iconSize.cy), &brush);
VERIFY(pStateList->Draw(&memDC, 0, iconPos, ILD_NORMAL));
memDC.SelectObject(pBmpOld);
VERIFY(imagelist.Add(&dstBmp, oldBkColor) != -1);
pBmpOld = memDC.SelectObject(&dstBmp);
memDC.FillRect(CRect(0, 0, iconSize.cx, iconSize.cy), &brush);
VERIFY(pStateList->Draw(&memDC, 1, iconPos, ILD_NORMAL));
memDC.SelectObject(pBmpOld);
VERIFY(imagelist.Add(&dstBmp, oldBkColor) != -1);
pStateList->SetBkColor(oldBkColor);
}
if (createdStateImages)
owner.SetExtendedStyle(owner.GetExtendedStyle() & ~LVS_EX_CHECKBOXES);
return imageCount;
}
示例11: 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);
}
示例12: 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);
//.........这里部分代码省略.........
示例13: 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;
}
示例14: 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);
}
}
示例15: OnChanListNotify
BOOL CSelectChan::OnChanListNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NM_LISTVIEW *pNm = (NM_LISTVIEW *)lParam;
LV_DISPINFO *ptvd= (LV_DISPINFO *)lParam;
NMHDR *pnmhdr=(LPNMHDR )lParam;
UINT state;
DWORD dwpos;
LV_HITTESTINFO lvhti;
int iItemClicked;
switch (pnmhdr->code)
{
case NM_CLICK:
case NM_RCLICK:
{
CImageList *himl = m_chan.GetImageList(LVSIL_STATE);
int cxImage = 0, cyImage = 0;
if (himl)
{
IMAGEINFO im;
himl->GetImageInfo(0,&im);
cxImage=im.rcImage.right;
cyImage=im.rcImage.bottom;
}
// Find out where the cursor was
dwpos = GetMessagePos();
lvhti.pt.x = LOWORD(dwpos);
lvhti.pt.y = HIWORD(dwpos);
m_chan.ScreenToClient(&lvhti.pt);
if(lvhti.pt.x>cxImage) break;
// Now do a hittest with this point.
iItemClicked = m_chan.HitTest(&lvhti);
if (lvhti.flags & LVHT_ONITEMSTATEICON)
{
// Now lets get the state from the item and toggle it.
state = m_chan.GetItemState(iItemClicked,LVIS_STATEIMAGEMASK);
state = (state == 0x1000) ? 0x2000 : 0x1000;
/* {
LV_ITEM lvi;
int i,j,n;
union
{
struct LISTINDX lst;
LPARAM lParam;
} LL;
memset(&lvi,0,sizeof(lvi));
lvi.mask=LVIF_PARAM;
lvi.iItem=iItemClicked;
lvi.iSubItem=0;
PhasesList.GetItem(&lvi);
LL.lParam=lvi.lParam;
i=LL.lst.sta;
j=LL.lst.chan;
n=LL.lst.phase;
SEISMIC_PHASE *pPhase;
pPhase=allWSGPhases.GetPhase(i,j,n);*/
CString Chan=m_chan.GetItemText(iItemClicked,0);
if(state==0x2000)
{
SetChanDrawState(ActiveSta, Chan, TRUE);
}
else
{
SetChanDrawState(ActiveSta, Chan, FALSE);
}
}
m_chan.SetItemState(iItemClicked, state, LVIS_STATEIMAGEMASK);
SetModified(TRUE);
}
}
return CPropertyPage::OnNotify(wParam, lParam, pResult);
}