【发布时间】:2011-09-19 05:13:23
【问题描述】:
当我在 dc 上绘制文本时,文本出现边缘粗糙,并且在此 WindowProc 处理的多个窗口上,每个窗口之间的文本看起来都不一样,这看起来不专业。有没有办法画出来,让它有清晰、光滑的边缘?
case WM_PAINT:
{
GetClientRect(hwnd, &rect);
hdc = BeginPaint(hwnd, &ps);
hdcmem = CreateCompatibleDC(hdc);
BITMAP bm;
HBITMAP hbmold = (HBITMAP)SelectObject(hdcmem, gbutton);
GetObject(gbutton, sizeof(bm), &bm);
SetBkMode(hdcmem, TRANSPARENT);
SetTextColor(hdcmem, RGB(74,88,91));
HFONT hf = CreateFont(30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Myriad Pro");
HFONT hfold = (HFONT)SelectObject(hdcmem, hf);
//the next line works fine, but with rough text edges.
DrawText(hdcmem, L"Drag a\r\nFile\r\nHere", -1, &rect, DT_CENTER | DT_VCENTER );
SelectObject(hdcmem, hfold);
BitBlt(hdc, 0,0,bm.bmWidth,bm.bmHeight,hdcmem,0,0,SRCCOPY);
SelectObject(hdcmem, hbmold);
DeleteDC(hdcmem);
EndPaint(hwnd, &ps);
break;
}
【问题讨论】: