int CListViewCtrlEx::_DrawCheckBox( CDCHandle &dc, RECT &rcItem, BOOL bChecked, DWORD dwFlags ) { if(rcItem.left>-16) { CDC dcTmp; dcTmp.CreateCompatibleDC(dc); RECT rcCheckBox = _GetRectCheckBox( rcItem ); HBITMAP hBmpOld = NULL; int x=rcCheckBox.left + 3, y=rcCheckBox.top, nWidth=13, nHeight=13, xSrc=bChecked ? 0 : 13, ySrc=0; if(dwFlags&LISTITEM_CHECKBOX) { hBmpOld = dcTmp.SelectBitmap(m_bitmapCheck); dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCCOPY); } else { // Need Mask hBmpOld = dcTmp.SelectBitmap(m_bitmapRadioMask); dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCAND); dcTmp.SelectBitmap(m_bitmapRadio); dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCPAINT); } dcTmp.SelectBitmap(hBmpOld); dcTmp.DeleteDC(); } return 3 + 13 + 3; }
void KDrawFrame::Draw(CDCHandle& dc, CRect rct, COLORREF clrBk) { CBrush brush; brush.CreateSolidBrush(clrBk); HBRUSH hOldBrush = dc.SelectBrush(brush); // 绘制背景 dc.Rectangle(&rct); int left, top, right, botton; CSize size = GetBmpSize(m_bmpLeftTop); left = size.cx; top = size.cy; size = GetBmpSize(m_bmpRightBotton); right = size.cx; botton = size.cy; CDC hTmpDC; hTmpDC.CreateCompatibleDC(dc); HBITMAP bOldbmp = hTmpDC.SelectBitmap(m_bmpLeftTop); dc.BitBlt(0, 0, left, top, hTmpDC, 0, 0, SRCCOPY); size = GetBmpSize(m_bmpTopBoder); hTmpDC.SelectBitmap(m_bmpTopBoder); dc.StretchBlt(left, 0, rct.right-right, top, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); hTmpDC.SelectBitmap(m_bmpRightTop); dc.BitBlt(rct.right-right, 0, rct.right, top, hTmpDC, 0, 0, SRCCOPY); size = GetBmpSize(m_bmpLeftBoder); hTmpDC.SelectBitmap(m_bmpLeftBoder); dc.StretchBlt(0, top, left, rct.bottom-botton-top, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); size = GetBmpSize(m_bmpRightBoder); hTmpDC.SelectBitmap(m_bmpRightBoder); dc.StretchBlt(rct.right-right, top, right, rct.bottom-botton-top, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); hTmpDC.SelectBitmap(m_bmpLeftBotton); dc.BitBlt(0, rct.bottom-botton, left, botton, hTmpDC, 0, 0, SRCCOPY); size = GetBmpSize(m_bmpBottonBoder); hTmpDC.SelectBitmap(m_bmpBottonBoder); dc.StretchBlt(left, rct.bottom-botton, rct.right-right, botton, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); hTmpDC.SelectBitmap(m_bmpRightBotton); dc.BitBlt(rct.right-right, rct.bottom-botton, rct.right, botton, hTmpDC, 0, 0, SRCCOPY); hTmpDC.SelectBitmap(bOldbmp); dc.SelectBrush(hOldBrush); }
// returns 16, 24, 32 bit depth CLIB_API int GetFirstPixel(HBITMAP hBitmap, COLORREF& firstPixel) { BITMAP bmp; if (::GetObject(hBitmap, sizeof(bmp), &bmp) && bmp.bmBits) { if (bmp.bmBitsPixel > 16) { unsigned offset=(((bmp.bmWidth*bmp.bmBitsPixel/8)+3)/4) * 4 * (bmp.bmHeight-1); firstPixel = *(COLORREF*)((BYTE*)bmp.bmBits + offset); // in memory it is laid out as BGR, so convert to RGB... firstPixel = RGB(GetBValue(firstPixel), GetGValue(firstPixel), GetRValue(firstPixel)); return bmp.bmBitsPixel; } else { ATLASSERT(bmp.bmBitsPixel==16); // we need a temporary memory bitmap to paint into. CClientDC dcc(0); CMemBm bmpFirstPixel(dcc, 0, 0, 0, 1, 1); CDCHandle hdcH = bmpFirstPixel; HBITMAP hbmpold=dcc.SelectBitmap(hBitmap); hdcH.BitBlt(0, 0, 1, 1, dcc, 0, 0, SRCCOPY); dcc.SelectBitmap(hbmpold); // get trans color firstPixel = bmpFirstPixel.GetFirstPixel(); return bmp.bmBitsPixel; } } return 0; }
void CButtonST::DrawTheBitmap(CDCHandle pDC, bool bHasTitle, RECT &rItem, CRect &rCaption, bool bIsPressed, bool bIsDisabled) { CDC hdcBmpMem = 0; CBitmapHandle hbmOldBmp = 0; CDC hdcMem = 0; CBitmapHandle hbmT = 0; BYTE byIndex = 0; // Select the bitmap to use if (m_bIsCheckBox) { if (bIsPressed) { byIndex = 0; } else { byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1); } } else { if (m_bMouseOnButton || bIsPressed) { byIndex = 0; } else { byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1); } } CRect rImage; PrepareImageRect(bHasTitle, rItem, rCaption, bIsPressed, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, rImage); hdcBmpMem.CreateCompatibleDC(pDC); hbmOldBmp = hdcBmpMem.SelectBitmap(m_csBitmaps[byIndex].hBitmap); hdcMem.CreateCompatibleDC(0); hbmT = hdcMem.SelectBitmap(m_csBitmaps[byIndex].hMask); pDC.BitBlt(rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND); pDC.BitBlt(rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT); hdcMem.SelectBitmap(hbmT); hdcBmpMem.SelectBitmap(hbmOldBmp); }
void CGradient::Draw( CDCHandle pDC, int xDest, int yDest, int xSrc, int ySrc, int Width, int Height, DWORD Rop) { pDC.BitBlt(xDest, yDest, Width, Height, mpMemDC->m_hDC, xSrc, ySrc, Rop); }
void CMenuSkin::DrawMenuBorder(CDCHandle dc, HDC dcBack, const RECT &rect, bool bJustDrawBorder, bool bEraseBg) { RECT rcClient = { 0, 0, rect.right - rect.left, rect.bottom - rect.top }; if (bEraseBg) { dc.BitBlt(0, 0, rcClient.right, rcClient.bottom, dcBack, 5, 5, SRCCOPY); return; } if (bJustDrawBorder) { CRgn rgn0, rgn1; rgn0.CreateRectRgnIndirect(&rcClient); RECT rcCore = { MENU_MARGIN, MENU_MARGIN, rcClient.right - MENU_MARGIN, rcClient.bottom - MENU_MARGIN }; rgn1.CreateRectRgnIndirect(&rcCore); rgn0.CombineRgn(rgn1, RGN_XOR); dc.SelectClipRgn(rgn0); dc.BitBlt(0, 0, rcClient.right, rcClient.bottom, dcBack, 0, 0, SRCCOPY); dc.SelectClipRgn(NULL); } else dc.BitBlt(0, 0, rcClient.right, rcClient.bottom, dcBack, 0, 0, SRCCOPY); }
void CButtonST::PaintBk(CDCHandle pDC) { CWindow parent = GetParent(); CClientDC clDC(parent); CRect rect; CRect rect1; GetClientRect(rect); GetWindowRect(rect1); parent.ScreenToClient(rect1); if (m_dcBk == 0) { m_dcBk.CreateCompatibleDC(clDC); m_bmpBk.CreateCompatibleBitmap(clDC, rect.Width(), rect.Height()); m_pbmpOldBk = m_dcBk.SelectBitmap(m_bmpBk); m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), clDC, rect1.left, rect1.top, SRCCOPY); } pDC.BitBlt(0, 0, rect.Width(), rect.Height(), m_dcBk, 0, 0, SRCCOPY); }
void CDragWnd::OnPaint( CDCHandle dc ) { CRect rc; GetClientRect(rc); dc.BitBlt(0,0,rc.Width(),rc.Height(),m_memdc,0,0,SRCCOPY); }
void CMenuSkin::DrawMenuCoreBackgroundWithClientDC(CDCHandle dc, HDC dcBack, const RECT &rcClient) { dc.BitBlt(rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, dcBack, rcClient.left + MENU_MARGIN, rcClient.top + MENU_MARGIN, SRCCOPY); }
void CScanView::onDrawSelf(CDCHandle dc) { CDC memDC; CBitmap memBitmap; memDC.CreateCompatibleDC(dc); CRect clientRECT; this->GetClientRect(&clientRECT); memBitmap.CreateCompatibleBitmap(dc,clientRECT.Width() , clientRECT.Height()); HBITMAP oldBitmap = memDC.SelectBitmap(memBitmap); HPEN oldPen = memDC.SelectStockPen(DC_PEN); HBRUSH oldBrush = memDC.SelectStockBrush(NULL_BRUSH); HFONT oldFont = memDC.SelectFont(stdfont); memDC.SetBkMode(0); memDC.SetTextColor(RGB(90, 90, 90)); memDC.SetTextAlign(TA_CENTER | TA_BASELINE); memDC.SetDCPenColor(RGB(60,60,60)); CPoint centerPt(clientRECT.Width()/2, clientRECT.Height()/2); const int maxPixelR = min(clientRECT.Width(), clientRECT.Height())/2 - DEF_MARGIN; const float distScale = (float)maxPixelR/_current_display_range; char txtBuffer[100]; // plot rings for (int angle = 0; angle<360; angle += 30) { float rad = (float)(angle*PI/180.0); float endptX = sin(rad)*(maxPixelR+DEF_MARGIN/2) + centerPt.x; float endptY = centerPt.y - cos(rad)*(maxPixelR+DEF_MARGIN/2); memDC.MoveTo(centerPt); memDC.LineTo((int)endptX, (int)endptY); sprintf(txtBuffer, "%d", angle); memDC.TextOutA((int)endptX, (int)endptY, txtBuffer); } for (int plotR = maxPixelR; plotR>0; plotR-=DISP_RING_ABS_DIST) { memDC.Ellipse(centerPt.x-plotR, centerPt.y-plotR, centerPt.x+plotR, centerPt.y+plotR); sprintf(txtBuffer, "%.1f", (float)plotR/distScale); memDC.TextOutA(centerPt.x, centerPt.y-plotR, txtBuffer); } memDC.SelectStockBrush(DC_BRUSH); memDC.SelectStockPen(NULL_PEN); int picked_point = 0; float min_picked_dangle = 100; for (int pos =0; pos < (int)_scan_data.size(); ++pos) { float distPixel = _scan_data[pos].dist*distScale; float rad = (float)(_scan_data[pos].angle*PI/180.0); float endptX = sin(rad)*(distPixel) + centerPt.x; float endptY = centerPt.y - cos(rad)*(distPixel); float dangle = fabs(rad - _mouse_angle); if (dangle<min_picked_dangle) { min_picked_dangle = dangle; picked_point = pos; } int brightness = (_scan_data[pos].quality<<1) + 128; if (brightness>255) brightness=255; memDC.FillSolidRect((int)endptX-1,(int)endptY-1, 2, 2,RGB(0,brightness,brightness)); } memDC.SelectFont(bigfont); memDC.SetTextAlign(TA_LEFT | TA_BASELINE); memDC.SetTextColor(RGB(255,255,255)); sprintf(txtBuffer, "%.1f Hz (%d RPM)", _scan_speed, (int)(_scan_speed*60)); memDC.TextOutA(DEF_MARGIN, DEF_MARGIN + 40, txtBuffer); if ((int)_scan_data.size() > picked_point) { float distPixel = _scan_data[picked_point].dist*distScale; float rad = (float)(_scan_data[picked_point].angle*PI/180.0); float endptX = sin(rad)*(distPixel) + centerPt.x; float endptY = centerPt.y - cos(rad)*(distPixel); memDC.SetDCPenColor(RGB(129,10,16)); memDC.SelectStockPen(DC_PEN); memDC.MoveTo(centerPt.x,centerPt.y); memDC.LineTo((int)endptX,(int)endptY); memDC.SelectStockPen(NULL_PEN); memDC.FillSolidRect((int)endptX-1,(int)endptY-1, 2, 2,RGB(255,0,0)); memDC.SetTextColor(RGB(255,0,0)); sprintf(txtBuffer, "Current: %.2f Deg: %.2f", _scan_data[picked_point].dist, _scan_data[picked_point].angle); memDC.TextOutA(DEF_MARGIN, DEF_MARGIN + 20, txtBuffer); } dc.BitBlt(0, 0, clientRECT.Width(), clientRECT.Height() , memDC, 0, 0, SRCCOPY); memDC.SelectFont(oldFont); memDC.SelectBrush(oldBrush); memDC.SelectPen(oldPen); memDC.SelectBitmap(oldBitmap); }
void CDuiMenuODWnd::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) { CRect rcItem=lpDrawItemStruct->rcItem; DuiMenuItemData *pdmmi=(DuiMenuItemData*)lpDrawItemStruct->itemData; CDCHandle dc(lpDrawItemStruct->hDC); CDCHandle dcMem; dcMem.CreateCompatibleDC(dc); CBitmap bmp=CGdiAlpha::CreateBitmap32(dc,rcItem.Width(),rcItem.Height()); CBitmapHandle hOldBmp=dcMem.SelectBitmap(bmp); dcMem.BitBlt(0,0,rcItem.Width(),rcItem.Height(),dc,rcItem.left,rcItem.top,SRCCOPY); rcItem.MoveToXY(0,0); if(pdmmi) { MENUITEMINFO mii= {sizeof(MENUITEMINFO),MIIM_FTYPE,0}; HMENU menuPopup=pdmmi->hMenu; GetMenuItemInfo(menuPopup,pdmmi->nID,FALSE,&mii); BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED; BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED; BOOL bRadio = mii.fType&MFT_RADIOCHECK; m_pItemSkin->Draw(dcMem,rcItem,bSelected?1:0); //draw back //draw icon CRect rcIcon; rcIcon.left=rcItem.left+m_nIconMargin; rcIcon.right=rcIcon.left+m_szIcon.cx; rcIcon.top=rcItem.top+(rcItem.Height()-m_szIcon.cy)/2; rcIcon.bottom=rcIcon.top+m_szIcon.cy; if(bChecked) { if(m_pCheckSkin) { if(bRadio) m_pCheckSkin->Draw(dcMem,rcIcon,1); else m_pCheckSkin->Draw(dcMem,rcIcon,0); } } else if(pdmmi->itemInfo.iIcon!=-1 && m_pIconSkin) { m_pIconSkin->Draw(dcMem,rcIcon,pdmmi->itemInfo.iIcon); } rcItem.left=rcIcon.right+m_nIconMargin; //draw text CRect rcTxt=rcItem; rcTxt.DeflateRect(m_nTextMargin,0); dcMem.SetBkMode(TRANSPARENT); COLORREF crOld=dcMem.SetTextColor(bDisabled?m_crTxtGray:(bSelected?m_crTxtSel:m_crTxtNormal)); HFONT hOldFont=0; hOldFont=dcMem.SelectFont(m_hFont); dcMem.DrawText(pdmmi->itemInfo.strText,pdmmi->itemInfo.strText.GetLength(),&rcTxt,DT_SINGLELINE|DT_VCENTER|DT_LEFT); dcMem.SelectFont(hOldFont); dcMem.SetTextColor(crOld); if(bSelected && m_pItemSkin->GetStates()>2) { //draw select mask CRect rcItem=lpDrawItemStruct->rcItem; rcItem.MoveToXY(0,0); m_pItemSkin->Draw(dcMem,rcItem,2); } } else //if(strcmp("sep",pXmlItem->Value())==0) { m_pItemSkin->Draw(dcMem,rcItem,0); //draw back if(m_pIconSkin) { rcItem.left += m_pIconSkin->GetSkinSize().cx+m_nIconMargin*2; } if(m_pSepSkin) m_pSepSkin->Draw(dcMem,&rcItem,0); else { CGdiAlpha::DrawLine(dcMem, rcItem.left, rcItem.top, rcItem.right, rcItem.top, RGB(196,196,196), PS_SOLID); CGdiAlpha::DrawLine(dcMem, rcItem.left, rcItem.top+1, rcItem.right, rcItem.top+1, RGB(255,255,255), PS_SOLID); } } rcItem=lpDrawItemStruct->rcItem; dc.BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),dcMem,0,0,SRCCOPY); dcMem.SelectBitmap(hOldBmp); dcMem.DeleteDC(); bmp.DeleteObject(); }
void CListViewCtrlEx::_DrawNormalItem( LPDRAWITEMSTRUCT lpdis, const TListItem *pItem ) { if (!pItem) return; int nItem = lpdis->itemID; CDCHandle dc; dc.Attach(lpdis->hDC); HFONT hOldFont = dc.SelectFont(m_fontDef); BOOL bSelect = FALSE ; if ((lpdis->itemAction | ODA_SELECT) && (lpdis->itemState & ODS_SELECTED)) { bSelect = TRUE ; } if ( bSelect ) dc.FillSolidRect( &lpdis->rcItem, RGB(185,219,255)); else dc.FillSolidRect( &lpdis->rcItem, pItem->clrBg); // draw check box if( pItem->dwFlags&(LISTITEM_CHECKBOX|LISTITEM_RADIOBOX) ) _DrawCheckBox(dc, lpdis->rcItem, _super::GetCheckState(nItem), pItem->dwFlags); COLORREF oldClr = dc.GetTextColor(); for(int i=0; i<pItem->subItems.size(); ++i) { CRect rcSubItem; DWORD nMarginWidth = 0; CRect rcBounds; GetSubItemRect(nItem, i, LVIR_LABEL, &rcSubItem); nMarginWidth = LEFT_MARGIN_TEXT_COLUMN+3; if(i==0) { if( pItem->dwFlags&(LISTITEM_CHECKBOX|LISTITEM_RADIOBOX) ) { nMarginWidth+=rcSubItem.left; } else { rcSubItem.left -= 19; nMarginWidth+=5; } } #define DT_FLAGS_DRAW_TEXT (DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS|DT_VCENTER) rcSubItem.left += LEFT_MARGIN_TEXT_COLUMN; rcSubItem.right -= 3; const TListSubItem &subItem = pItem->subItems[i]; if(subItem.type == SUBITEM_LINK) { dc.SelectFont(m_fontLink); dc.SetTextColor(COLOR_LIST_LINK); CRect rcProbeItem; dc.DrawText( subItem.str, -1, &rcProbeItem, DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_VCENTER|DT_CALCRECT); dc.DrawText( subItem.str, -1, &rcSubItem, DT_FLAGS_DRAW_TEXT); DWORD nMaxWidth = rcProbeItem.Width()+nMarginWidth; _SetColumnNeedWidth(i,nMaxWidth); } else { if (subItem.type == SUBITEM_ICON && subItem.nImg != NULL) { dc.DrawIconEx( rcSubItem.left, rcSubItem.top + 3, (HICON)subItem.nImg, 16 , 16, 0, 0, DI_NORMAL ); rcSubItem.left = rcSubItem.left + 18; } else if (subItem.type == SUBITEM_PNG) { Gdiplus::Image* pImg = BkPngPool::Get(subItem.nImg); if (pImg) { Gdiplus::Graphics graphics(dc); SIZE size = {0, 0}; if (pImg) { size.cx = pImg->GetWidth(); size.cy = pImg->GetHeight(); } graphics.DrawImage(pImg, Gdiplus::Rect(rcSubItem.left, rcSubItem.top + 5, size.cx, size.cy)); } rcSubItem.left = rcSubItem.left + 18; } else if(subItem.type==SUBITEM_COMBO) { CDC dcTmp; dcTmp.CreateCompatibleDC(dc); HBITMAP hBmpOld = dcTmp.SelectBitmap(m_bitmapCombo); dc.BitBlt(rcSubItem.right-20, rcSubItem.top + 3, 20, 20, dcTmp, 0, 0, SRCCOPY); dcTmp.SelectBitmap(hBmpOld); dcTmp.DeleteDC(); } UINT uFormat = DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_PATH_ELLIPSIS|DT_VCENTER; if (i == 3) { if (pItem->nLevel == enumLevelRisk) { rcSubItem.DeflateRect(2, 3); CPen penBorder; penBorder.CreatePen( PS_SOLID, 1, RGB(224, 0, 0) ); CBrush bshInterior; bshInterior.CreateSolidBrush( RGB(224, 0, 0) ); HPEN hOldPen = dc.SelectPen( penBorder ); HBRUSH hOldBrush = dc.SelectBrush( bshInterior ); dc.RoundRect( rcSubItem, CPoint( 3, 3 ) ); dc.SelectPen(hOldPen); dc.SelectBrush(hOldBrush); dc.SetTextColor( RGB(255, 255, 255) ); } else if (pItem->nLevel == enumLevelUnknown) { rcSubItem.DeflateRect(2, 3); CPen penBorder; penBorder.CreatePen( PS_SOLID, 1, RGB(250, 115, 5) ); CBrush bshInterior; bshInterior.CreateSolidBrush( RGB(250, 115, 5) ); HPEN hOldPen = dc.SelectPen( penBorder ); HBRUSH hOldBrush = dc.SelectBrush( bshInterior ); dc.RoundRect( rcSubItem, CPoint( 3, 3 ) ); dc.SelectPen(hOldPen); dc.SelectBrush(hOldBrush); dc.SetTextColor( RGB(255, 255, 255) ); } else dc.SetTextColor( subItem.clr ); uFormat = DT_SINGLELINE|DT_CENTER|DT_NOPREFIX|DT_PATH_ELLIPSIS|DT_VCENTER; } else dc.SetTextColor( subItem.clr ); dc.DrawText( subItem.str, -1, &rcSubItem, uFormat); if (subItem.type == SUBITEM_ICON || subItem.type == SUBITEM_PNG) rcSubItem.left = rcSubItem.left - 18; CRect rcProbeItem; dc.DrawText( subItem.str, -1, &rcProbeItem, DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_VCENTER|DT_CALCRECT); DWORD nMaxWidth = rcProbeItem.Width()+nMarginWidth; _SetColumnNeedWidth(i,nMaxWidth); } } CPen penx; penx.CreatePen(PS_SOLID,1,pItem->clrBtmGapLine); HPEN penOld = dc.SelectPen(penx); dc.MoveTo( lpdis->rcItem.left, lpdis->rcItem.bottom-1 ); CRect rcClient; GetClientRect(rcClient); dc.LineTo( lpdis->rcItem.left + rcClient.Width(), lpdis->rcItem.bottom-1); dc.SelectPen(penOld); dc.SelectFont(hOldFont); dc.SetTextColor(oldClr); dc.Detach(); }
void CListViewCtrlEx::_DrawTitleItem( LPDRAWITEMSTRUCT lpdis, const TListItem *pItem ) { ATLASSERT(pItem); if(pItem->subItems.empty()) return ; int nWinWidth=lpdis->rcItem.right-lpdis->rcItem.left; CRect rcWindows; GetWindowRect(rcWindows); if ( nWinWidth > rcWindows.Width()) nWinWidth = rcWindows.Width()-20; int nItem = lpdis->itemID; CDCHandle dc; dc.Attach(lpdis->hDC); dc.FillSolidRect( &lpdis->rcItem, pItem->clrBg); HFONT hOldFont = dc.SelectFont(m_fontDef); COLORREF clrOld = dc.GetTextColor(); COLORREF clrDef = clrOld; // RECT rcItem = lpdis->rcItem; if( pItem->dwFlags&LISTITEM_EXPANDABLE ) { //3 + 9 + 3 if(rcItem.left>-12) { CDC dcTmp; dcTmp.CreateCompatibleDC(dc); HBITMAP hBmpOld = dcTmp.SelectBitmap(m_bitmapExpand); RECT rcMinus = _GetRectMinus(rcItem); dc.BitBlt( rcMinus.left, rcMinus.top, 9, 9, dcTmp, pItem->_isclapsed? 9:0, 0, SRCCOPY); dcTmp.SelectBitmap(hBmpOld); } } for ( int i = 0; i < pItem->subItems.size(); i++) { bool bVCenter=TRUE; const TListSubItem& subItem = pItem->subItems[i]; CRect rcItem = subItem.rcOffset; if ( i == 0 ) { rcItem = lpdis->rcItem; if(pItem->nTopMargin>=0) { rcItem.top += pItem->nTopMargin; rcItem.bottom -= 0; bVCenter=FALSE; } else { rcItem.top += 2; rcItem.bottom -= 2; } rcItem.left+= pItem->nLeftmargin; } else { if ( rcItem.left < 0 ) { rcItem.left = nWinWidth+rcItem.left; } if (rcItem.right < 0) { rcItem.right = nWinWidth+rcItem.right; } rcItem.OffsetRect( lpdis->rcItem.left, lpdis->rcItem.top); } if ( subItem.type == SUBITEM_TEXT ) { dc.SetTextColor( subItem.clr); dc.SelectFont(m_fontDef); } else if ( subItem.type == SUBITEM_LINK ) { dc.SelectFont(m_fontLink); dc.SetTextColor(COLOR_LIST_LINK); } else { dc.SetTextColor( subItem.clr); dc.SelectFont(m_fontDef); } CString strTitle = subItem.str; DWORD nFlag=DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS; if(bVCenter) nFlag|=DT_VCENTER; if (i==0&&pItem->bBold||pItem->nHeightAdd!=0) { HFONT fntOld=dc.SelectFont(BkFontPool::GetFont(pItem->bBold,FALSE,FALSE,pItem->nHeightAdd)); dc.DrawText( strTitle, -1, &rcItem, nFlag); dc.SelectFont(fntOld); } else dc.DrawText( strTitle, -1, &rcItem, nFlag); } CPen pex; pex.CreatePen(PS_SOLID,1,pItem->clrBtmGapLine); HPEN penOld = dc.SelectPen(pex); dc.MoveTo( lpdis->rcItem.left, lpdis->rcItem.bottom-1 ); dc.LineTo( lpdis->rcItem.right, lpdis->rcItem.bottom-1 ); dc.SetTextColor(clrOld); dc.SelectPen(penOld); dc.SelectFont(hOldFont); dc.Detach(); }