Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2647563
  • 博文数量: 416
  • 博客积分: 10220
  • 博客等级: 上将
  • 技术积分: 4193
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-15 09:47
文章分类

全部博文(416)

文章存档

2022年(1)

2021年(1)

2020年(1)

2019年(5)

2018年(7)

2017年(6)

2016年(7)

2015年(11)

2014年(1)

2012年(5)

2011年(7)

2010年(35)

2009年(64)

2008年(48)

2007年(177)

2006年(40)

我的朋友

分类: C/C++

2007-12-05 09:39:48

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();
}
阅读(1985) | 评论(1) | 转发(0) |
0

上一篇:php array数组

下一篇:如何这般隐藏表格行

给主人留下些什么吧!~~