• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CMemDC 사용법 (double buffering)
    Last Modify : 27 December, 2010(12:10)
    CRect rect, rectItem;
    GetClientRect(&rect);
    CMemDC mDC(&dc, &rect);
    
    CDC bitmapDC;
    bitmapDC.CreateCompatibleDC(&dc);
    
    CBitmap bmpLeft, bmpCenter, bmpRight;
    CBitmap bmpLeftOver, bmpCenterOver, bmpRightOver;
    
    bmpLeft.LoadBitmap(IDB_LISTBG_LEFT);
    bmpCenter.LoadBitmap(IDB_LISTBG_CENTER);
    bmpRight.LoadBitmap(IDB_LISTBG_RIGHT);
    
    bmpLeftOver.LoadBitmap(IDB_LISTBG_LEFT_OVER);
    bmpCenterOver.LoadBitmap(IDB_LISTBG_CENTER_OVER);
    bmpRightOver.LoadBitmap(IDB_LISTBG_RIGHT_OVER);
    
    // 전체적인 중간 이미지
    int nWidth		= rect.Width();// - 16;
    CBitmap* pOldBitmap2	= bitmapDC.SelectObject(&bmpCenter);
    mDC.StretchBlt(rect.left+8, 0, nWidth, 19, &bitmapDC, 0,0, 1, 19, SRCCOPY);
    bitmapDC.SelectObject(pOldBitmap2);
    
    CFont font;
    LOGFONT lf;
    memset(&lf, 0, sizeof(LOGFONT));
    lf.lfHeight = 13;
    wsprintf(lf.lfFaceName, L"Tahoma");
    font.CreateFontIndirect(&lf);
    CFont* def_font = mDC.SelectObject(&font);
    mDC.SetBkMode(TRANSPARENT);
    
    for (i=0; i<nItems; ++i)
    {
    	wchar_t wszBuff[256];
    	CBitmap* pOldBitmap = NULL;
    	HD_ITEM hdItem;
    
    	hdItem.mask		= HDI_TEXT | HDI_FORMAT | HDI_ORDER;
    	hdItem.pszText		= wszBuff;
    	hdItem.cchTextMax	= 255;
    	GetItem(i, &hdItem);
    	GetItemRect(i, &rect);
    	
    	
    	pOldBitmap = bitmapDC.SelectObject(&bmpLeftOver);
    	mDC.BitBlt(rect.left, rect.top, 8, 19, &bitmapDC, 0, 0, SRCCOPY);
    		
    	bitmapDC.SelectObject(pOldBitmap);
    
    	int nWidth = rect.Width();// - 16;
    	CBitmap* pOldBitmap2 = bitmapDC.SelectObject(&bmpCenter);
    	mDC.StretchBlt(rect.left+8, 0, nWidth, 19, &bitmapDC, 0,0, 1, 19, SRCCOPY);
    	bitmapDC.SelectObject(pOldBitmap2);
    
    	// 세번째 ] 이미지
    	CBitmap* pOldBitmap3 = bitmapDC.SelectObject(&bmpRight);
    	mDC.BitBlt((rect.right-8), 0, 8, 19, &bitmapDC,0,0,SRCCOPY);
    	bitmapDC.SelectObject(pOldBitmap3);
    
    	// 글내 텍스트
    	GetItemRect(i, &rectItem);		
    	UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_TOP | DT_CENTER | DT_END_ELLIPSIS ;
    	rectItem.DeflateRect(2,2,2,2);
    	mDC.DrawText(wszBuff, &rectItem, uFormat);		
    }
    
    mDC.SelectObject(def_font);
    font.DeleteObject();

    Comment


    입력하3 1508772463



    Locations of visitors to this page