posts - 131, comments - 12, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

MFC美化

Posted on 2013-03-29 17:30 盛胜 阅读(429) 评论(0)  编辑 收藏 引用
OnPain()
CPaintDC *pdc=&dc;
CRect r;
GetClientRect(&r);
CBitmap *pBitmap= new CBitmap;
BITMAP bm;
pBitmap->LoadBitmap(IDB_BG_NEW);
pBitmap->GetBitmap(&bm);
CDC* pDisplayMemDC = new CDC;
pDisplayMemDC->CreateCompatibleDC(pdc);
pDisplayMemDC->SelectObject(pBitmap);
pdc->StretchBlt(r.left,r.top+30,r.Width(),r.Height()-30,pDisplayMemDC,
0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
pBitmap->DeleteObject();

ReleaseDC(pdc);
ReleaseDC(pDisplayMemDC);
delete pDisplayMemDC;
delete pBitmap;

OnCtlColor
//修改窗口控件背景颜色
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(#dedede);
pDC->SetBkColor(#383838);
hbr = CreateSolidBrush(#383838);
}
if (nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetTextColor(#dedede);
pDC->SetBkColor(#13344d);
hbr = CreateSolidBrush(#13344d);
}
OnEraseBkgnd
CRect windowRect;
GetWindowRect(windowRect);
ScreenToClient(windowRect);
pDC->FillSolidRect(windowRect, #383838);
return TRUE;

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理