使用这个完整的示例,我可以在 Aero Glass 上绘制文本。渲染非常好,但存在视觉问题:发光在文本对齐侧被剪裁。
仅供参考,文本格式定义如下:
Dim uFormat As Integer = TextFormatFlags.NoPrefix Or TextFormatFlags.WordBreak Or _
TextFormatFlags.TextBoxControl Or TextFormatFlags.EndEllipsis
这可以解决吗?
使用这个完整的示例,我可以在 Aero Glass 上绘制文本。渲染非常好,但存在视觉问题:发光在文本对齐侧被剪裁。
仅供参考,文本格式定义如下:
Dim uFormat As Integer = TextFormatFlags.NoPrefix Or TextFormatFlags.WordBreak Or _
TextFormatFlags.TextBoxControl Or TextFormatFlags.EndEllipsis
这可以解决吗?
默认情况下,此示例使用中间居中对齐文本。您使用的格式 (NoPrefix|WordBreak|TextBoxControl|EndEllipsis) 默认为左对齐。因此,要修复辉光剪辑,您应该扩展辉光边界。
这是更正后的样本:
public void DrawTextOnGlass(IntPtr hwnd, String text, Font font, Rectangle bounds, int glowSize){
//...
RECT glowRect = new RECT();
RECT textRect = new RECT();
glowRect.left = bounds.Left - glowSize;
glowRect.right = bounds.Right + glowSize;
glowRect.top = bounds.Top - glowSize;
glowRect.bottom = bounds.Bottom + glowSize;
textRect.left = glowSize;
textRect.top = glowSize;
textRect.right = glowRect.right - glowRect.left;
textRect.bottom = glowRect.bottom - glowRect.top;
//...
int uFormat = (int)(TextFormatFlags.NoPrefix
| TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.EndEllipsis);
//...
DrawThemeTextEx(renderer.Handle, Memdc, 0, 0, text, -1, uFormat, ref textRect, ref dttOpts);
BitBlt(destdc, glowRect.left, glowRect.top,
glowRect.right - glowRect.left,
glowRect.bottom - glowRect.top,
Memdc, 0, 0, SRCCOPY);
//...
}