Esempio n. 1
0
void CTrashSkipCtrl::_DrawSoftItem(CDC& dc, CRect& rcDraw, int nItemIndex)
{
    TRASH_SKIP_ITEM item = m_vecItems[nItemIndex];
    HICON hIcon = NULL;
    CRect rcCloseBtn(rcDraw);
    int xSrc;

    _DrawItemBackgnd(dc, rcDraw, nItemIndex);

    Gdiplus::Graphics graphics(dc);

    rcCloseBtn.left = rcDraw.right - 25;
    rcCloseBtn.bottom = rcDraw.top + 25;
    if (m_nHoverIndex == nItemIndex && m_nSelectIndex == -1)
    {
        xSrc = 25;
    }
    else if (m_nSelectIndex == nItemIndex)
    {
        xSrc = 50;
    }
    else
    {
        xSrc = 0;
    }
    graphics.DrawImage(m_imgSoftOff, rcCloseBtn.left, rcCloseBtn.top, xSrc, 0, 25, 25, Gdiplus::UnitPixel);

    ::CopyRect(m_vecItems[nItemIndex].rcItem, rcCloseBtn);


    _GetItemIcon(item.strIconPath, hIcon);

    CRect rcIcon(rcDraw);

    rcIcon.left += (DEF_ITEM_WIDTH - 6 - 32) / 2;
    rcIcon.top += 24;

    if (!hIcon)
    {            
        KAppRes& res = KAppRes::Instance();

        if (item.nItemID == BROWER_IE)
        {
            hIcon = m_iconIE;
        }
        else
        {
            hIcon = m_iconUnknow;
        }
        dc.DrawIcon(rcIcon.left, rcIcon.top, hIcon);
    }
    else
    {
        dc.DrawIconEx(rcIcon.left, rcIcon.top, hIcon, 32, 32);
    }

    _DrawItemText(dc, rcDraw, item.strName);

    if (hIcon && (hIcon != m_iconIE && hIcon != m_iconUnknow))
    {
        DestroyIcon(hIcon);
    }
}