本文整理汇总了C++中CHeaderCtrl::GetImageList方法的典型用法代码示例。如果您正苦于以下问题:C++ CHeaderCtrl::GetImageList方法的具体用法?C++ CHeaderCtrl::GetImageList怎么用?C++ CHeaderCtrl::GetImageList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHeaderCtrl
的用法示例。
在下文中一共展示了CHeaderCtrl::GetImageList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertMenu
void InsertMenu(CListCtrl& list,
CMenu* pMenu,
UINT nIndex, // Menu id to remplace
CImageList* pImageList)
{
CHeaderCtrl *pHeader = list.GetHeaderCtrl();
int nbCol = pHeader->GetItemCount();
int nAfter = -1, id;
char buffer[maxTitleLength];
HDITEM hi;
if (pImageList == NULL) pImageList = pHeader->GetImageList();
hi.mask = HDI_FORMAT|HDI_IMAGE|HDI_LPARAM|HDI_TEXT;
hi.pszText = buffer;
hi.cchTextMax = maxTitleLength;
while (--nbCol >= 0) {
pHeader->GetItem(nbCol, &hi);
if (hi.lParam == 0) continue;
// there is a sort possible column
id = nIndex + nbCol;
if (nAfter < 0) {
if (!pMenu->ModifyMenu(nIndex, MF_BYCOMMAND|MF_STRING, id, buffer))
return;
} else {
pMenu->InsertMenu(nAfter, MF_BYCOMMAND|MF_STRING, id, buffer);
}
if (hi.iImage && pImageList) {
static CBitmap bm, *pOldBm;
IMAGEINFO ii;
CDC dcMem;
// fill a bitmap with the sort image
pImageList->GetImageInfo(hi.iImage, &ii);
int w = ii.rcImage.right - ii.rcImage.left;
int h = ii.rcImage.bottom - ii.rcImage.top;
dcMem.CreateCompatibleDC(NULL);
if (bm.m_hObject) bm.DeleteObject();
bm.CreateCompatibleBitmap(&dcMem, w, h);
pOldBm = dcMem.SelectObject(&bm);
dcMem.FillSolidRect(0, 0, w, h, 0xFFFFFF);
pImageList->Draw(&dcMem, hi.iImage, CPoint(0,0), ILD_NORMAL);
dcMem.SelectObject(pOldBm);
// display the sort icon
pMenu->SetMenuItemBitmaps(id, MF_BYCOMMAND, &bm, &bm);
}
nAfter = id;
}
}