中科因仑“3+1”工程特种兵精英论坛
标题: win32与winCE下MFC背景贴图、静态文字背景透明 [打印本页]
作者: leixiaofeng 时间: 2015-3-21 17:04
标题: win32与winCE下MFC背景贴图、静态文字背景透明
win32上可以重载OnCtlColor,字体背景透明:
- if(nCtlColor == CTLCOLOR_STATIC)
- {
- pDC->SetBkMode(TRANSPARENT);
- return (HBRUSH)::GetStockObject(NULL_BRUSH);
- }
CE下无效,只好放弃删掉控件,在onpaint中写,
在CE下,没有textout这个函数,可以用ExtTextOut。
- void CNaviUpdateToolsDialog::OnPaint()
- {
- #if defined WINCE
- #else
- OutputDebugStringA("onpaint");
- #endif
- CPaintDC dc(this); // device context for painting
- CRect rect;
- GetClientRect(&rect);
- CDC dcMem;
- dcMem.CreateCompatibleDC(&dc);
- <span style="white-space:pre"> </span>CBitmap m_bmpBackground;
- m_bmpBackground.LoadBitmap(IDB_BACK);
- BITMAP bitmap;
- m_bmpBackground.GetBitmap(&bitmap);
- CBitmap *pbmpOld=dcMem.SelectObject(&m_bmpBackground);
- dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);
- // dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,SRCCOPY);
- dc.SetBkMode(TRANSPARENT);
- CFont font;
- font.CreatePointFont(150,L"微软雅黑",&dc);
- dc.SelectObject(&font);
- dc.ExtTextOut(350,150,0,&rect,"wenzi",NULL);
- dc.ExtTextOut(350,180,0,&rect,"wenzi",NULL);
- }
欢迎光临 中科因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) |
Powered by Discuz! X3.4 |