|

楼主 |
发表于 2012-5-4 00:06:00
|
显示全部楼层
Re:DDraw剪裁器剪裁::DrawTextW的问题 急啊
Text Render源码
void CDDrawFont ::RenderW(const wchar_t *wszText, const RECT &dstRect, DWORD color, DWORD brushColor/* = 0*/, UINT format/* = 0*/)
{
if (m_pDDrawSystem == NULL) return;
if (m_hFont == NULL) return;
if (color == 0) return;
HDC hDC = GetDC();
if (hDC == NULL) return;
SetTextColor(hDC, DDRAW_RGB_TO_BGR(color));
if (brushColor > 0)
{
SetBkColor(hDC, DDRAW_RGB_TO_BGR(brushColor));
SetBkMode(hDC, OPAQUE);
}
else
{
SetBkMode(hDC, TRANSPARENT);
}
// 因为不能删除当前选中的对象,所以这里要保存旧对象,以使最后能够把当前对象替换下来,完成删除
HFONT hOldFont = (HFONT)SelectObject(hDC, m_hFont);
: rawTextW(hDC, wszText, int(wcslen(wszText)), (LPRECT)&dstRect, format);
// 恢复旧对象,以使得最后可以顺利删除m_hFont对象
if (hOldFont != NULL)
{
::SelectObject(hDC, hOldFont);
hOldFont = NULL;
}
ReleaseDC(hDC);
}
求分析 |
|