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);
- }
|