void CitemView::OnDraw(CDC* pDC)
{
CitemDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CFont m_StdFont;
CFont m_UnderlineFont;
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont->GetSafeHandle());
getBitMap( pDC );
// Create the underline font
LOGFONT lf;
pFont->GetLogFont(&lf);
m_StdFont.CreateFontIndirect(&lf);
lf.lfUnderline = (BYTE) TRUE;
lf.lfItalic = (BYTE) TRUE;
lf.lfHeight = 25;
strcpy(lf.lfFaceName , "Arial");
m_UnderlineFont.CreateFontIndirect(&lf);
// TODO: add draw code for native data here
CString str("master help");
CString str1("master help mfc");
CRect rc(10, 20, 250, 350);
//CDC *pDC = GetDC();
int nPrevMode = pDC->SetBkMode( TRANSPARENT );
pDC->SelectObject( &m_UnderlineFont );
pDC->SetBkColor( RGB(60, 50, 30));
pDC->SetTextColor(RGB(50, 0, 0));
pDC->TextOut( 100, 100, str1);
pDC->SetTextColor(RGB(255, 0, 0));
pDC->TextOut( 101, 100, str1);
pDC->SetBkMode( nPrevMode );
pDC->DrawText(str, rc, DT_WORDBREAK );
ReleaseDC( pDC );
}
void CitemView::getBitMap( CDC *pDC )
{
CDC MemDC;
HBITMAP hBmp;
BITMAP bm;
CBitmap Bitmap;
CPoint point( 10, 10);
CString cStr;
CRect rc;
//hBmp = (HBITMAP)::LoadImage(NULL,"BG.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),"BG.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
Bitmap.DeleteObject();
Bitmap.Attach( hBmp );
Bitmap.GetObject(sizeof(BITMAP),&bm);
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(&Bitmap);
GetClientRect( &rc );
//pDC->BitBlt(point.x, point.y, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY);
CBrush brush(&Bitmap);
pDC->FillRect( &rc, &brush);
//pDC->SetStretchBltMode( COLORONCOLOR );
//pDC->StretchBlt(point.x, point.y, rc.Width(), rc.Height(), &MemDC, bm.bmWidth, 0, 0, bm.bmHeight, SRCCOPY);
//pDC->BitBlt(point.x, point.y, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCAND);
MemDC.DeleteDC();
}
阅读(2020) | 评论(1) | 转发(0) |