我有一个SetBkMode
问题TRANSPARENT
。在绘制新文本之前,之前的文本不会从位图中清除。这是绘图的代码。
void PaintWindow(WTL::CDCHandle dc)
{
CRect rcWindow;
HFONT hPrevFont, hFont;
DWORD dwStyle;
UINT uTextFormat;
ATLVERIFY(GetWindowRect(rcWindow));
dwStyle = GetStyle();
// Setup Font to use.
hFont = GetFont();
if (hFont != nullptr)
hPrevFont = dc.SelectFont(hFont);
else
hPrevFont = nullptr;
// Setup Text Format.
uTextFormat = 0;
if (dwStyle & SS_ENDELLIPSIS)
uTextFormat |= DT_END_ELLIPSIS;
if (dwStyle & SS_NOPREFIX)
uTextFormat |= DT_NOPREFIX;
if (dwStyle & SS_RIGHT)
uTextFormat |= DT_RIGHT;
// Draw Text.
dc.SetTextColor(m_crTextColor);
dc.SetBkMode(TRANSPARENT);
dc.DrawText(m_strText, m_strText.GetLength(), CRect(0, 0, rcWindow.Width(), rcWindow.Height()), uTextFormat);
// Clean up.
if (hPrevFont != nullptr)
dc.SelectFont(hPrevFont);
}
感谢提前。